MCPcopy Create free account
hub / github.com/Snapchat/Valdi / runShell

Method runShell

npm_modules/cli/src/setup/DevSetupHelper.ts:37–54  ·  view source on GitHub ↗
(
    guide: string,
    commands: string[],
    additionalEnvVariables: { [key: string]: string } = {},
  )

Source from the content-addressed store, hash-verified

35 await fs.promises.writeFile(dest, new Uint8Array(body));
36 }
37
38 async runShell(
39 guide: string,
40 commands: string[],
41 additionalEnvVariables: { [key: string]: string } = {},
42 ): Promise<string> {
43 let command = '';
44 for (const key in additionalEnvVariables) {
45 command += `export ${key}="${additionalEnvVariables[key] as string}"\n`;
46 }
47 command += commands.join(' && ');
48 console.log(`${wrapInColor(guide, ANSI_COLORS.YELLOW_COLOR)}...`);
49 for (const command of commands) {
50 console.log(`- ${command}`);
51 }
52
53 try {
54 const result = await spawnCliCommand(command, undefined, 'inherit', false, true);
55 return result.stdout;
56 } catch (error) {
57 // stdio is inherited, so the underlying error message is empty: say what failed instead.

Callers 2

macOSSetupFunction · 0.95
linuxSetupFunction · 0.95

Calls 4

wrapInColorFunction · 0.90
spawnCliCommandFunction · 0.90
logMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected