10 examples of 'node run command' in JavaScript

Every line of 'node run command' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
181export function runNode(verbose = false, args: string[]) {
182 return _run({ silent: !verbose }, "node", args);
183}
74function run(cmd, args)
75{
76 console.log('>', cmd, args.join(' '));
77 var result = child_process.spawnSync(
78 cmd,
79 args,
80 {
81 cwd: process.cwd(),
82 env: process.env,
83 stdio: 'inherit'
84 }
85 );
86 if (result.error)
87 throw result.error;
88 return result;
89}
17function run(cmd, args) {
18 const result = spawnSync(cmd, args, { stdio: "inherit" });
19 if (result.error) {
20 console.log(result.error);
21 process.exit(1);
22 }
23}
81async function run(args, cwd, commandOptions) {
82 const options = Object.assign(
83 {
84 cwd,
85 reject: false,
86 all: true
87 },
88 commandOptions || {}
89 );
90
91 options.env = Object.assign({ TESTING_CRAFTY: "true" }, options.env || {});
92
93 const ret = await execa.node(
94 require.resolve("@swissquote/crafty/src/bin"),
95 args,
96 options
97 );
98
99 return {
100 status: ret.exitCode,
101 stdall: ret.all ? `\n${snapshotizeOutput(ret.all.toString("utf8"))}\n` : ""
102 };
103}
19function run (cmd) {
20 var file = path.resolve(process.cwd(), cmd[0]);
21 var src = fs.readFileSync(file);
22 fs.writeFileSync(__dirname + '/work/x.js', src);
23 cmd[0] = __dirname + '/work/x.js';
24
25 var opts = { cwd: __dirname + '/work' };
26 return spawn(process.execPath, cmd, opts);
27}
108export async function run(cwd: string, cmd: string): Promise {
109 const { stdout } = await execa(cmd, { shell: true, cwd });
110
111 return stdout;
112}
4async function run (cmd, opts = {}) {
5 const gitdocs = path.resolve(__dirname, '../bin/gitdocs')
6 return execa(gitdocs, cmd.split(' '), opts)
7}
11function run(command: string, args: string[]): string {
12 return String(execa.sync(command, args, { preferLocal: true }).stdout);
13}
143function run(cwd, command, ...args) {
144 console.log("Executing:", command, args.join(" "));
145 return new Promise((resolve, reject) => {
146 const proc = spawn(command, args, {
147 cwd,
148 stdio: ["ignore", "ignore", "pipe"]
149 });
150 const buffers = [];
151 proc.stderr.on("data", data => buffers.push(data));
152 proc.on("error", () => {
153 reject(new Error(`command failed: ${command}`));
154 });
155 proc.on("exit", code => {
156 if (code === 0) {
157 resolve(true);
158 } else {
159 const stderr = Buffer.concat(buffers)
160 .toString("utf8")
161 .trim();
162 if (stderr) {
163 console.log(`command failed with code ${code}`);
164 console.log(stderr);
165 }
166 reject(new ExitError(code));
167 }
168 });
169 });
170}
6function run(command, commandScript) {
7
8 return new Promise((resolve) => {
9
10 exec(commandScript, (error, stdout, stderr) => {
11
12 if (stderr && error) {
13 resolve(null, stderr.replace(/\r?\n|\r/, '').trim());
14 } else {
15 resolve(stdout.replace(/\r?\n|\r/, '').trim(), null);
16 }
17
18 });
19 });
20}

Related snippets