1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/fs/exec-file.injectable.ts
Janne Savolainen ec78080d99
Make opening of release details work properly when release has resources without namespace (#6088)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>
Co-authored-by: Sebastian Malton <sebastian@malton.name>
2022-09-08 13:57:11 -04:00

29 lines
807 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { ExecFileOptions } from "child_process";
import { execFile } from "child_process";
import { promisify } from "util";
export type ExecFile = (filePath: string, args: string[], options: ExecFileOptions) => Promise<string>;
const execFileInjectable = getInjectable({
id: "exec-file",
instantiate: (): ExecFile => {
const asyncExecFile = promisify(execFile);
return async (filePath, args, options) => {
const result = await asyncExecFile(filePath, args, options);
return result.stdout;
};
},
causesSideEffects: true,
});
export default execFileInjectable;