(command: string, childOptions: childProcess.SpawnOptions)
| 9 | import { isVSCodeExtension } from "../vsCodeUtils"; |
| 10 | |
| 11 | function 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 | |
| 48 | function getChildEnvironment(target: string, overallOptions: any, config: any) { |
| 49 | // active project ID |
no test coverage detected
searching dependent graphs…