How to use the mz/child_process.exec function in mz

To help you get started, we’ve selected a few mz 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 electron-userland / electron-installer-debian / test / helpers / dependencies.js View on Github external
assertDependenciesEqual: function assertDependenciesEqual (outputDir, debFilename, userDependencies) {
    const dpkgDebCmd = `dpkg-deb -f ${debFilename} Depends Recommends Suggests Enhances Pre-Depends`
    return exec(dpkgDebCmd, { cwd: outputDir })
      .then(stdout => {
        const baseDependencies = {
          Depends: _.sortBy(_.union(defaults.depends, userDependencies.depends)),
          Recommends: _.sortBy(_.union(defaults.recommends, userDependencies.recommends)),
          Suggests: _.sortBy(_.union(defaults.suggests, userDependencies.suggests)),
          Enhances: _.sortBy(_.union(defaults.enhances, userDependencies.enhances)),
          'Pre-Depends': _.sortBy(_.union(defaults.preDepends, userDependencies.preDepends))
        } // object with both user and default dependencies based on src/installer.js

        // Creates object based on stdout (values are still strings)
        let destDependencies = _.fromPairs(_.chunk(_.initial(stdout.toString().split(/\n|:\s/)), 2))
        // String values are mapped into sorted arrays
        destDependencies = _.mapValues(destDependencies, function (value) {
          if (value) return _.sortBy(value.split(', '))
        })
github Polymer / tools / packages / modulizer / src / tools / update-fixtures.ts View on Github external
console.log(`Cloning ${options.repoUrl} #${branch} to ${sourceDir}...`);
    await fs.ensureDir(fixturesDir);
    await fs.remove(sourceDir);

    await exec(
        `git clone ${options.repoUrl} ${sourceDir} --branch=${
            branch} --depth=1`,
        {cwd: fixturesDir});
    await fs.remove(path.join(sourceDir, '.git'));
    await fs.remove(path.join(sourceDir, '.github'));
    await fs.remove(path.join(sourceDir, '.gitignore'));

    await overridePolymer(sourceDir);

    await exec('bower install', {cwd: sourceDir});
  }

  const testConfig = require(path.join(fixturesDir, 'test.js')) as TestConfig;
  await runFixture(sourceDir, convertedDir, testConfig);

  // Our integration tests always skip bower_components when comparing, so
  // there's no reason to check them into git.
  await fs.remove(path.join(convertedDir, 'bower_components'));

  console.log(`Done.`);
}
github shoutem / cli / src / extension / platform-manager.js View on Github external
export async function nativeRun(opts) {
  const path = opts.mobileapp || await getAppDir(opts.appId);

  await syncApp(path, opts);

  const packagerPromise = startPackager(path, { resolveOnReady: true });

  try {
    const runResult = await platform.runPlatform(path, opts);
    const output = runResult.stdout + runResult.stderr;

    if (output.indexOf('Code signing is required for product type') > 0) {
      let xcodeProjectPath = join(path, 'ios', 'ShoutemApp.xcworkspace');
      console.log('Select ShoutemApp target from xcode and activate "Automatically manage signing", ' +
        'select a provisioning profile and then rerun `shoutem run-ios`.');
      await exec(`open "${xcodeProjectPath}"`);
      const packagerProcess = (await packagerPromise).childProcess;
      await packagerProcess.kill('SIGINT');
    }
  } catch (exc) {
    try {
      const packagerProcess = (await packagerPromise).childProcess;
      await packagerProcess.kill('SIGINT');
    } catch (err) {
      // ignored
    }

    throw exc;
  }
}
github shoutem / cli / src / commands / shoutem-run.js View on Github external
if (output.indexOf('Code signing is required for product type') > 0) {
    let xcodeProjectPath;
    // if platform is used
    // last runtime configuration is required to get the mobile-app directory
    if (platformPath) {
      const runtimeConfig = await readJsonFile(await getPlatformConfigPath());
      const platform = _.find(runtimeConfig.included, {type: 'shoutem.core.platform-installations'});
      const version = _.get(platform, 'attributes.mobileAppVersion');
      xcodeProjectPath = path.join(await getPlatformsPath(), `v${version}`, 'ios', 'ShoutemApp.xcodeproj');
    } else {
      xcodeProjectPath = path.join(buildDirectory, 'ios', 'ShoutemApp.xcodeproj');
    }

    console.log('Select ShoutemApp target from xcode and activate "Automatically manage signing", ' +
      'select a provisioning profile and then rerun `shoutem run-ios`.');
    await exec(`open "${xcodeProjectPath}"`);
    return null;
  }

  if (output.indexOf('Unable to find a destination matching the provided destination specifier') > 0) {
    console.log('The app couldn\'t be run because of outdated Xcode version. Please update Xcode to 8.2.1 or later'.bold.red);
    return null;
  }

  console.log('Packager is being run within this process. Please keep this process running if app is used in debug mode'.bold.yellow);

  await packagerPromise;
}
github Eugeny / terminus / terminus-terminal / src / persistence / screen.ts View on Github external
async terminateSession (recoveryId: string): Promise {
        try {
            await exec(`screen -S ${recoveryId} -X quit`)
        } catch (_) {
            // screen has already quit
        }
    }
github mozilla-b2g / fxos-device-service / src / sendFromDevice.js View on Github external
async function copyToLocal(adb, source, local, options) {
  let filename = path.basename(source);
  if (!options.isFolder) {
    await adb.pull(source, local);
    return path.resolve(local, filename);
  }

  // The dot is for recursive copy according to
  // android.stackexchange.com/questions/87326/recursive-adb-pull
  await adb.pull(`${source}/.`, local);
  await exec(`tar -cf ${filename}.tar *`, {cwd: local});
  await exec(`gzip ${filename}.tar`, {cwd: local});
  return path.resolve(local, `${filename}.tar.gz`);
}
github nicojs / node-link-parent-bin / test / integration / sample.spec.ts View on Github external
const execInSample = (cmd: string, cwd = '') => {
    console.log(`exec: ${cmd}`);
    return childProcess.exec(cmd, { cwd: resolve(cwd) }).then(output => {
        const stdout = output[0].toString();
        const stderr = output[1].toString();
        if (stdout) {
            console.log(`stdout: ${stdout}`);
        }
        if (stderr) {
            console.error(`stderr: ${stderr}`);
        }
        return { stdout, stderr };
    });
}
github decaffeinate / bulk-decaffeinate / src / config / resolveConfig.js View on Github external
async function resolveBinary(binaryName) {
  let nodeModulesPath = `./node_modules/.bin/${binaryName}`;
  if (await exists(nodeModulesPath)) {
    return nodeModulesPath;
  } else {
    try {
      await exec(`which ${binaryName}`);
      return binaryName;
    } catch (e) {
      console.log(`${binaryName} binary not found on the PATH or in node_modules.`);
      let rl = readline.createInterface(process.stdin, process.stdout);
      let answer = await rl.question(`Run "npm install -g ${binaryName}"? [Y/n] `);
      rl.close();
      if (answer.toLowerCase().startsWith('n')) {
        throw new CLIError(`${binaryName} must be installed.`);
      }
      console.log(`Installing ${binaryName} globally...`);
      await execLive(`npm install -g ${binaryName}`);
      console.log(`Successfully installed ${binaryName}\n`);
      return binaryName;
    }
  }
}
github Neckster / chartjs-plugin-piechart-outlabels / gulpfile.js View on Github external
exec([cmd, script, 'install', './'].join(' ')).then(() => {
		return exec([cmd, script, 'build', './', out].join(' '));
	}).then(() => {
		done();
github DylanPiercey / local-devices / src / index.js View on Github external
function arpOne (address) {
  if (!ip.isV4Format(address) && !ip.isV6Format(address)) {
    return Promise.reject(new Error('Invalid IP address provided.'))
  }

  return cp.exec('arp -n ' + address, options).then(parseOne)
}