congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo For Javascript
exec
Code IndexAdd Tabnine to your IDE (free)

How to use
exec
function
in
child_process

Best JavaScript code snippets using child_process.exec(Showing top 15 results out of 3,069)

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: Sly777/ran

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

const cmder = async cmd => {
  return new Promise((resolve, reject) => {
    exec(cmd, (err, stdout, stderr) => {
      if(err) {
        reject(err);
        return;
      }
      resolve('success');
    })
  })
}
origin: reactide/reactide

exec(
  command,
  {
   cwd: cwd
  },
  (err, stdout, stderr) => {
   if(err) console.log(err);
   global.mainWindow.webContents.send('craOut', stdout)
   fs.writeFileSync(path.resolve(dest, '.env'), 'SKIP_PREFLIGHT_CHECK=true\nBROWSER=none', { encoding: 'utf8' }, (err) => {
    if(err) console.log(err);
   });
   global.mainWindow.webContents.send('openDir', dest);
  }
 )
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: GoogleCloudPlatform/nodejs-docs-samples

describe('lookupEntry lookup', () => {
 it('should lookup a dataset entry', (done) => {
  const projectId = 'bigquery-public-data';
  const datasetId = 'new_york_taxi_trips';
  const expectedLinkedResource = `//bigquery.googleapis.com/projects/${projectId}/datasets/${datasetId}`;
  exec(
   `node lookupEntry.js ${projectId} ${datasetId}`,
   {cwd},
   (err, stdout) => {
    assert.ok(stdout.includes(expectedLinkedResource));
    done();
   }
  );
 });
});
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: laurent22/joplin

exec(command, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
      if (error) {

        // Special case for robocopy, which will return non-zero error codes
        // when sucessful. Doc is very imprecise but <= 7 seems more or less
        // fine and >= 8 seems more errorish. https://ss64.com/nt/robocopy-exit.html
        if (command.indexOf('robocopy') === 0 && error.code <= 7) {
          resolve(stdout.trim());
          return;
        }

        if (error.signal == 'SIGTERM') {
          resolve('Process was killed');
        } else {
          const newError = new Error(`Code: ${error.code}: ${error.message}: ${stdout.trim()}`);
          reject(newError);
        }
      } else {
        resolve(stdout.trim());
      }
    });
origin: GladysAssistant/Gladys

// 20 MB

/**
 * @description Execute a command and return results.
 * @param {string} command - The command to execute.
 * @returns {Promise} Resolve if command resolve.
 * @example
 * exec('ls');
 */
function exec(command) {
 return new Promise((resolve, reject) => {
  childProcess.exec(command, { maxBuffer: MAX_BUFFER_SIZE }, (err, stdout, stderr) => {
   if (err) {
    logger.debug(`Exec: Fail to execute command ${command}`);
    logger.debug(err);
    logger.debug(stderr);
    return reject(err);
   }

   return resolve(stdout);
  });
 });
}
origin: Sly777/ran

/**
 * Installs dependencies
 */
function installDeps() {
 exec('node --version', (err, stdout) => {
  const nodeVersion = stdout && parseFloat(stdout.substring(1));
  if (nodeVersion < 7 || err) {
   installDepsCallback(
    err ||
     'Unsupported node.js version, make sure you have the latest version installed.'
   );
  } else {
   installDepsCallback();
  }
 });
}
origin: reactide/reactide

const closeSim = (pid) => {
  //Killall Node
  let command = `kill -9 ${pid}`
  let child = exec(
   command,
   (err, stdout, stderr) => {
    if(err) console.log(err);
    global.mainWindow.webContents.send('closeSim', 'helloworld');
   }
  );
 }
origin: GoogleCloudPlatform/nodejs-docs-samples

describe('server listening', () => {
 it('should be listening', async () => {
  await childProcess.exec(`node ${appPath}`);
  const isOpen = await waitPort({port: PORT});
  expect(isOpen).to.be.true;
 });
});
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: deepsyx/home-automation

function pwm (pin, value) {
  return exec(`echo "${pin}=${parseFloat(value)}" > /dev/pi-blaster`);
}
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_processexec

Most used child_process functions

  • spawn
  • execSync
  • ChildProcess.on
  • ChildProcessWithoutNullStreams.stdout
  • ChildProcessWithoutNullStreams.on
  • 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

  • aws-sdk
    AWS SDK for JavaScript
  • chalk
    Terminal string styling done right
  • lodash
    Lodash modular utilities.
  • colors
    get colors in your node.js console
  • yargs
    yargs the modern, pirate-themed, successor to optimist.
  • fs
  • body-parser
    Node.js body parsing middleware
  • redis
    Redis client library
  • winston
    A logger for just about everything.
  • Top Vim plugins
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