MCPcopy Create free account
hub / github.com/firebase/firebase-tools / runCommand

Function runCommand

src/deploy/lifecycleHooks.ts:11–46  ·  view source on GitHub ↗
(command: string, childOptions: childProcess.SpawnOptions)

Source from the content-addressed store, hash-verified

9import { isVSCodeExtension } from "../vsCodeUtils";
10
11function runCommand(command: string, childOptions: childProcess.SpawnOptions) {
12 const escapedCommand = command.replace(/\"/g, '\\"');
13 const nodeExecutable = isVSCodeExtension() ? "node" : process.execPath;
14 const crossEnvShellPath = isVSCodeExtension()
15 ? path.resolve(__dirname, "./cross-env/dist/bin/cross-env-shell.js")
16 : path.resolve(require.resolve("cross-env"), "..", "bin", "cross-env-shell.js");
17 const translatedCommand =
18 '"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';
19
20 return new Promise<void>((resolve, reject) => {
21 logger.info("Running command: " + command);
22 if (command.includes("=")) {
23 utils.logWarning(
24 clc.yellow(clc.bold("Warning: ")) +
25 "Your command contains '=', it may result in the command not running." +
26 " Please consider removing it.",
27 );
28 }
29 if (translatedCommand === "") {
30 return resolve();
31 }
32 const child = childProcess.spawn(translatedCommand, [], childOptions);
33 child.on("error", (err) => {
34 reject(err);
35 });
36 child.on("exit", (code, signal) => {
37 if (signal) {
38 reject(new Error("Command terminated with signal " + signal));
39 } else if (code !== 0) {
40 reject(new Error("Command terminated with non-zero exit code " + code));
41 } else {
42 resolve();
43 }
44 });
45 });
46}
47
48function getChildEnvironment(target: string, overallOptions: any, config: any) {
49 // active project ID

Callers 1

runTargetCommandsFunction · 0.70

Calls 4

isVSCodeExtensionFunction · 0.90
resolveFunction · 0.85
onMethod · 0.80
rejectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…