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

How to use child_process

Best JavaScript code snippets using child_process(Showing top 15 results out of 8,217)

origin: coryhouse/react-slingshot

exec('node -v', function (err, stdout) {
 if (err) throw err;

 if (parseFloat(stdout.slice(1)) < 8) {
  throw new Error('React Slingshot requires node 8.0 or greater.');
 }
});
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: cube-js/cube.js

function isInMercurialRepository() {
 try {
  execSync('hg --cwd . root', { stdio: 'ignore' });
  return true;
 } catch (e) {
  return false;
 }
}
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

child.stdout.on("data", msg => {
   msg = msg
    .toString()
    .split("\n")
    .filter(m => {
     return m.indexOf("already satisfied") === -1;
    })
    .join("\n");
   process.stdout.write(msg);
  });
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: remoteinterview/zero

child.on("close", async () => {
   var pip = await getPipExe();

   if (pip) {
    console.log("Pip installation completed.");
    resolve(pip);
   } else {
    console.log("Pip installation failed. Please install manually.");
   }
  });
origin: Automattic/wp-calypso

function spawnDetached( cwd, command, args, output, env ) {
  const stdio = output ? [ 'ignore', output, output ] : null;
  const app = spawn( command, args, { stdio, detached: true, env, cwd } );
  app.on( 'error', ( err ) => {
    throw `failed to initialize command "${ command }": "${ err }"`;
  } );
  return app;
}
origin: laurent22/joplin

exec(command, (error, stdout) => {
      if (error) {
        if (error.signal == 'SIGTERM') {
          resolve('Process was killed');
        } else {
          reject(error);
        }
      } else {
        resolve(stdout.trim());
      }
    });
origin: deepsyx/home-automation

function turn (pin, state) {
  const value = state ? 1 : 0;
  exec(`gpio -g mode ${pin} out`);
  return exec(`gpio -g write ${pin} ${value}`);
}
origin: Sly777/ran

/**
 * Initializes git again
 */
function initGit(callback) {
 exec('git init && git add . && git commit -m "Initial commit"', callback);
}
origin: cube-js/cube.js

function isInGitRepository() {
 try {
  execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
  return true;
 } catch (e) {
  return false;
 }
}
origin: remoteinterview/zero

child.stdout.on("data", msg => {
   msg = msg
    .toString()
    .split("\n")
    .filter(m => {
     return m.indexOf("already satisfied") === -1;
    })
    .join("\n");
   process.stdout.write(msg);
  });
origin: cube-js/cube.js

function isInMercurialRepository() {
 try {
  execSync('hg --cwd . root', { stdio: 'ignore' });
  return true;
 } catch (e) {
  return false;
 }
}
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');
 });
});
child_process

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

  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • minimist
    parse argument options
  • async
    Higher-order functions and common patterns for asynchronous code
  • commander
    the complete solution for node.js command-line programs
  • winston
    A logger for just about everything.
  • crypto
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • 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