forked from fern-api/fern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunScript.ts
More file actions
28 lines (27 loc) · 753 Bytes
/
Copy pathrunScript.ts
File metadata and controls
28 lines (27 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Logger } from "@fern-api/logger";
import { loggingExeca } from "@fern-api/logging-execa";
import { writeFile } from "fs/promises";
import tmp from "tmp-promise";
export async function runScript({
commands,
workingDir,
logger,
doNotPipeOutput,
env
}: {
commands: string[];
workingDir: string;
logger: Logger;
doNotPipeOutput: boolean;
env?: Record<string, string>;
}): Promise<loggingExeca.ReturnValue> {
const scriptFile = await tmp.file();
await writeFile(scriptFile.path, [`cd ${workingDir}`, ...commands].join("\n"));
return await loggingExeca(logger, "bash", [scriptFile.path], {
doNotPipeOutput,
env: {
...process.env,
...env
}
});
}