Remove mac-ca usage since it was only in tests (#6043) (#6321)

* Remove mac-ca usage since it was only in tests (#6043)

* Make injecting CAs injectable, remove mac-ca as dependency
* Fix win-ca failing on electron renderer on windows
* Fix the matcher under features/ for main

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix type errors from new types

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Temp change to see windows errors on CI

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix temp change

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Change error message for windows

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Increase maxBuffer size when reading windows CAs

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Switch back to running integration tests on windows

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix usage after rebase

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Update lock file

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-11-22 15:23:01 -05:00
1 parent 6d7090f8a7
commit 0eee5a07c5
24 files changed
+293 -271

No files matched your search

+37 -15
View File
@@ -7,28 +7,50 @@ import type { ExecFileException, ExecFileOptions } from "child_process";
import { execFile } from "child_process";
import type { AsyncResult } from "../utils/async-result";
export type ExecFileError = ExecFileException & { stderr: string };
export interface ExecFile {
(filePath: string, args: string[], options?: ExecFileOptions): Promise<AsyncResult<string, ExecFileException & { stderr: string }>>;
(filePath: string): Promise<AsyncResult<string, ExecFileError>>;
(filePath: string, argsOrOptions: string[] | ExecFileOptions): Promise<AsyncResult<string, ExecFileError>>;
(filePath: string, args: string[], options: ExecFileOptions): Promise<AsyncResult<string, ExecFileError>>;
}
const execFileInjectable = getInjectable({
id: "exec-file",
instantiate: (): ExecFile => (filePath, args, options) => new Promise((resolve) => {
execFile(filePath, args, options ?? {}, (error, stdout, stderr) => {
if (error) {
resolve({
callWasSuccessful: false,
error: Object.assign(error, { stderr }),
instantiate: (): ExecFile => {
return (filePath: string, argsOrOptions?: string[] | ExecFileOptions, maybeOptions?: ExecFileOptions) => {
const { args, options } = (() => {
if (Array.isArray(argsOrOptions)) {
return {
args: argsOrOptions,
options: maybeOptions ?? {},
};
} else {
return {
args: [],
options: argsOrOptions ?? {},
};
}
})();
return new Promise((resolve) => {
execFile(filePath, args, options, (error, stdout, stderr) => {
if (error) {
resolve({
callWasSuccessful: false,
error: Object.assign(error, { stderr }),
});
} else {
resolve({
callWasSuccessful: true,
response: stdout,
});
}
});
} else {
resolve({
callWasSuccessful: true,
response: stdout,
});
}
});
}),
});
};
},
causesSideEffects: true,
});