mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
This reverts commit f544386619.
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
1a8f80a5e9
commit
ed073d6562
25 files changed
+262
-250
No files matched your search
@@ -7,11 +7,7 @@ import type { ExecFileOptions } from "child_process";
|
||||
import { execFile } from "child_process";
|
||||
import { promisify } from "util";
|
||||
|
||||
export interface ExecFile {
|
||||
(filePath: string): Promise<string>;
|
||||
(filePath: string, argsOrOptions: string[] | ExecFileOptions): Promise<string>;
|
||||
(filePath: string, args: string[], options: ExecFileOptions): Promise<string>;
|
||||
}
|
||||
export type ExecFile = (filePath: string, args: string[], options: ExecFileOptions) => Promise<string>;
|
||||
|
||||
const execFileInjectable = getInjectable({
|
||||
id: "exec-file",
|
||||
@@ -19,22 +15,8 @@ const execFileInjectable = getInjectable({
|
||||
instantiate: (): ExecFile => {
|
||||
const asyncExecFile = promisify(execFile);
|
||||
|
||||
return async (filePath: string, argsOrOptions?: string[] | ExecFileOptions, maybeOptions?: ExecFileOptions) => {
|
||||
let args: string[];
|
||||
let options: ExecFileOptions;
|
||||
|
||||
if (Array.isArray(argsOrOptions)) {
|
||||
args = argsOrOptions;
|
||||
options = maybeOptions ?? {};
|
||||
} else {
|
||||
args = [];
|
||||
options = maybeOptions ?? argsOrOptions ?? {};
|
||||
}
|
||||
|
||||
const result = await asyncExecFile(filePath, args, {
|
||||
encoding: "utf-8",
|
||||
...options,
|
||||
});
|
||||
return async (filePath, args, options) => {
|
||||
const result = await asyncExecFile(filePath, args, options);
|
||||
|
||||
return result.stdout;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user