How to use the cross-spawn.default function in cross-spawn

To help you get started, we’ve selected a few cross-spawn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nodkz / mongodb-memory-server / packages / mongodb-memory-server-core / src / util / MongoInstance.ts View on Github external
_launchKiller(parentPid: number, childPid: number): ChildProcess {
    this.debug(`Called MongoInstance._launchKiller(parent: ${parentPid}, child: ${childPid}):`);
    // spawn process which kills itself and mongo process if current process is dead
    const killer = spawnChild(
      process.argv[0],
      [
        path.resolve(__dirname, '../../scripts/mongo_killer.js'),
        parentPid.toString(),
        childPid.toString(),
      ],
      { stdio: 'pipe' }
    );

    ['exit', 'message', 'disconnect', 'error'].forEach((e) => {
      killer.on(e, (...args) => {
        this.debug(`[MongoKiller]: ${e} - ${JSON.stringify(args)}`);
      });
    });

    return killer;
github nodkz / mongodb-memory-server / packages / mongodb-memory-server-core / src / util / MongoInstance.ts View on Github external
_launchMongod(mongoBin: string): ChildProcess {
    const spawnOpts = this.opts.spawn || {};
    if (!spawnOpts.stdio) spawnOpts.stdio = 'pipe';
    const childProcess = spawnChild(mongoBin, this.prepareCommandArgs(), spawnOpts);
    if (childProcess.stderr) {
      childProcess.stderr.on('data', this.stderrHandler.bind(this));
    }
    if (childProcess.stdout) {
      childProcess.stdout.on('data', this.stdoutHandler.bind(this));
    }
    childProcess.on('close', this.closeHandler.bind(this));
    childProcess.on('error', this.errorHandler.bind(this));

    return childProcess;
  }