Tabnine Logo For Javascript
ChildProcess
Code IndexAdd Tabnine to your IDE (free)

How to use
ChildProcess
in
child_process

Best JavaScript code snippets using child_process.ChildProcess(Showing top 15 results out of 2,169)

origin: cube-js/cube.js

const executeCommand = (command, args) => {
 const child = spawn(command, args, { stdio: 'inherit' });
 return new Promise((resolve, reject) => {
  child.on('close', code => {
   if (code !== 0) {
    reject(new Error(`${command} ${args.join(' ')} failed with exit code ${code}`));
    return;
   }
   resolve();
  });
 });
}
origin: pinojs/pino

function test (file) {
 file = join('fixtures', 'broken-pipe', file)
 t.test(file, { parallel: true }, async ({ is }) => {
  const child = fork(join(__dirname, file), { silent: true })
  child.stdout.destroy()

  child.stderr.pipe(process.stdout)

  const res = await once(child, 'close')
  is(res, 0) // process exits successfully
 })
}
origin: cube-js/cube.js

app.get('/playground/dashboard-app-status', catchErrors(async (req, res) => {
   this.cubejsServer.event('Dev Server Dashboard App Status');
   const dashboardPort = this.dashboardAppProcess && await this.dashboardAppProcess.dashboardUrlPromise;
   res.json({
    running: !!dashboardPort,
    dashboardPort,
    dashboardAppPath: path.resolve(dashboardAppPath)
   });
  }));
origin: GoogleCloudPlatform/nodejs-docs-samples

describe('server listening', () => {
 it('should be listening', async () => {
  const child = childProcess.exec(`node ${appPath}`);
  const isOpen = await waitPort({port: PORT});
  expect(isOpen).to.be.true;
  process.kill(child.pid, 'SIGTERM');
 });
});
origin: laurent22/joplin

child.on('close', (code) => {
      if (code !== 0) {
        reject(`Ended with code ${code}`);
      } else {
        resolve();
      }
    });
origin: mixn/carbon-now-cli

test.serial('Running `carbon-now` fails without file or stdin', async t => {
  try {
    // https://github.com/sindresorhus/get-stdin/issues/13#issuecomment-279234249
    const command = exec(`node ${SCRIPT}`);
    command.childProcess.stdin.end();
    await command;
    t.fail();
  } catch (error) {
    t.pass();
  }
});
origin: pinojs/pino

test('do not use SonicBoom is someone tampered with process.stdout.write', async ({ isNot }) => {
 var actual = ''
 const child = fork(join(__dirname, 'fixtures', 'stdout-hack-protection.js'), { silent: true })

 child.stdout.pipe(writer((s, enc, cb) => {
  actual += s
  cb()
 }))
 await once(child, 'close')
 isNot(actual.match(/^hack/), null)
})
origin: remoteinterview/zero

// we open a 4th stdio as IPC doesn't work on windows for python->node
  child.stdio[4].on("data", async function(message) {
   await waitPort({
    port: parseInt(message.toString()),
    output: "silent",
    timeout: 1000 * 60 * 2 // 2 Minutes
   });
   resolve(expressWrap(message.toString().trim()));
  });
origin: FormidableLabs/nodejs-dashboard

child.stdout.on("data", (data) => {
 dashboard.onEvent({ type: "stdout",
  data: data.toString("utf8") });
});
origin: hilongjw/vue-zhihu-daily

runner.on('exit', function (code) {
 server.close()
 process.exit(code)
})
origin: FormidableLabs/nodejs-dashboard

child.stderr.on("data", (data) => {
 dashboard.onEvent({ type: "stderr",
  data: data.toString("utf8") });
});
origin: hilongjw/vue-zhihu-daily

runner.on('error', function (err) {
 server.close()
 throw err
})
origin: cube-js/cube.js

function executeCommand(command, args, options = {}) {
 const child = spawn(command, args, { stdio: 'inherit', ...options });

 return new Promise((resolve, reject) => {
  child.on('close', (code) => {
   if (code !== 0) {
    reject(new Error(`${command} ${args.join(' ')} failed with exit code ${code}. Please check your console.`));
    return;
   }
   resolve();
  });
 });
}
origin: GoogleCloudPlatform/nodejs-docs-samples

describe('gae_flex_postgres_connect', () => {
 it('should be listening', async () => {
  const child = childProcess.exec(`node ${appPath}`);
  const isOpen = await waitPort({port: PORT});
  expect(isOpen).to.be.true;
  process.kill(child.pid, 'SIGTERM');
 });
});
origin: remoteinterview/zero

// we open a 4th stdio as IPC doesn't work on windows for python->node
  child.stdio[4].on("data", async function(message) {
   await waitPort({
    port: parseInt(message.toString()),
    output: "silent",
    timeout: 1000 * 60 * 2 // 2 Minutes
   });
   resolve(expressWrap(message.toString().trim()));
  });
child_processChildProcess

Most used child_process functions

  • exec
  • spawn
  • execSync
  • ChildProcess.on
  • ChildProcessWithoutNullStreams.stdout
  • ChildProcessWithoutNullStreams.stderr,
  • fork,
  • ChildProcess.pid,
  • ChildProcess.stdout,
  • execFile,
  • ChildProcess.stderr,
  • ChildProcessWithoutNullStreams.kill,
  • spawnSync,
  • ChildProcess.kill,
  • ChildProcessWithoutNullStreams.stdin,
  • ChildProcess.send,
  • ExecException.message,
  • ChildProcess.once,
  • SpawnSyncReturns.status

Popular in JavaScript

  • ms
    Tiny millisecond conversion utility
  • mocha
    simple, flexible, fun test framework
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • commander
    the complete solution for node.js command-line programs
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • mongodb
    The official MongoDB driver for Node.js
  • request
    Simplified HTTP request client.
  • aws-sdk
    AWS SDK for JavaScript
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now