How to use the execa.sync function in execa

To help you get started, we’ve selected a few execa 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 cypress-io / cypress-test-example-repos / test-repo.js View on Github external
.then((json) => {
  // we need this tool, so save its path right now
  // const cmi = resolve(join('node_modules', '.bin', 'commit-message-install'))

  // need to clone entire repo so we get all branches
  // because we might be testing in a separate branch
  execa.sync(`git clone ${url} ${localFolder}`, execOptions)

  console.log('cloned into folder %s', localFolder)
  shell.cd(localFolder)

  const branch = json && json.branch

  if (branch) {
    console.log('commit message specifies branch to test', branch)
    console.log('trying to switch to remote branch', branch)
    const cmd = `git checkout ${branch}`
    try {
      execa.sync(cmd, execOptions)
    } catch (e) {
      console.error('Caught error trying to do', cmd)
      console.error(e.message)
      console.error('assuming we can work in the default branch')
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / index.ts View on Github external
});

  if (process.platform === 'darwin') {
    try {
      return execa.sync(
        'open',
        ['-a', terminal, launchPackagerScript],
        procConfig,
      );
    } catch (error) {
      return execa.sync('open', [launchPackagerScript], procConfig);
    }
  }
  if (process.platform === 'linux') {
    try {
      return execa.sync(terminal, ['-e', `sh ${launchPackagerScript}`], {
        ...procConfig,
        detached: true,
      });
    } catch (error) {
      // By default, the child shell process will be attached to the parent
      return execa.sync('sh', [launchPackagerScript], procConfig);
    }
  }
  if (/^win/.test(process.platform)) {
    //Temporary fix for #484. See comment on line 254
    fs.writeFileSync(launchPackagerScript, launchPackagerScriptContent, {
      encoding: 'utf8',
      flag: 'w',
    });

    // Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
github x-orpheus / elint / test / system / utils.js View on Github external
function npmCheck() {
  const version = execa.sync('npm', ['-v']).stdout;
  const versions = version.split('.');

  if (versions[0] !== '5' || !['4', '5', '6'].includes(versions[1])) {
    return;
  }

  console.log('升级 npm');

  if (process.platform === 'win32') {
    execa.sync('npm', ['install', 'npm', '-g']);
  } else {
    execa.sync('sudo', ['npm', 'install', 'npm', '-g']);
  }
}
github ember-cli / ember-cli / lib / models / hardware-info.js View on Github external
function isUsingBatteryWindows() {
  try {
    const { stdout } = execa.sync('wmic', [
      '/namespace:',
      '\\\\root\\WMI',
      'path',
      'BatteryStatus',
      'get',
      'PowerOnline',
      '/format:list',
    ]);

    return /\bPowerOnline=FALSE\b/.test(stdout);
  } catch (ex) {
    logger.warn(`Could not get battery status from wmic: ${ex}`);
    logger.warn(ex.stack);

    return null;
  }
github elastic / kibana / x-pack / legacy / plugins / canvas / scripts / storybook_dll.js View on Github external
const fs = require('fs');
const path = require('path');
const execa = require('execa');
const devUtils = require('@kbn/dev-utils');
const { DLL_OUTPUT } = require('./../.storybook/constants');

const log = new devUtils.ToolingLog({
  level: 'info',
  writeTo: process.stdout,
});

if (fs.existsSync(DLL_OUTPUT)) {
  log.info('storybook: DLL exists from previous build');
} else {
  log.info('storybook: DLL missing; building');
  execa.sync(
    'yarn',
    [
      'webpack',
      '--config',
      'x-pack/legacy/plugins/canvas/.storybook/webpack.dll.config.js',
      '--progress',
      '--hide-modules',
      '--display-entrypoints',
      'false',
    ],
    {
      cwd: path.resolve(__dirname, '../../../../..'),
      stdio: ['ignore', 'inherit', 'inherit'],
      buffer: false,
    }
  );
github react-native-community / cli / packages / platform-android / src / commands / runAndroid / index.ts View on Github external
const buildDirectory = `${appFolder}/build/outputs/apk/${variant}`;
    const apkFile = getInstallApkName(
      appFolder,
      adbPath,
      variant,
      device,
      buildDirectory,
    );

    const pathToApk = `${buildDirectory}/${apkFile}`;
    const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];
    logger.info(`Installing the app on the device "${device}"...`);
    logger.debug(
      `Running command "cd android && adb -s ${device} install -r -d ${pathToApk}"`,
    );
    execa.sync(adbPath, adbArgs, {stdio: 'inherit'});
  } catch (error) {
    throw new CLIError('Failed to install the app on the device.', error);
  }
}
github sindresorhus / username / index.js View on Github external
const envVariable = getEnvironmentVariable();
	if (envVariable) {
		return envVariable;
	}

	const userInfoUsername = getUsernameFromOsUserInfo();
	if (userInfoUsername) {
		return userInfoUsername;
	}

	try {
		if (process.platform === 'win32') {
			return cleanWindowsCommand(execa.sync('whoami').stdout);
		}

		const userId = execa.sync('id', ['-u']).stdout;
		try {
			return execa.sync('id', ['-un', userId]).stdout;
		} catch (_) {}

		return makeUsernameFromId(userId);
	} catch (_) {}
});
github emberjs / data / bin / packages-for-commit.js View on Github external
function execWithLog(command, force) {
  debug(chalk.cyan('Executing: ') + chalk.yellow(command));
  if (debug.enabled || force) {
    return execa.sync(command, { stdio: [0, 1, 2], shell: true });
  }

  return execa.sync(command, { shell: true }).stdout;
}
github silverwind / default-gateway / sunos.js View on Github external
const sync = family => {
  const {stdout} = execa.sync("netstat", args[family]);
  return parse(stdout);
};
github fabiospampinato / cliflix / dist / index.js View on Github external
return __generator(this, function (_a) {
                webtorrentOptions = utils_1.default.webtorrent.options.parse(webtorrentOptions, config_1.default.webtorrent.options);
                execArgs = ['download', torrent].concat(webtorrentOptions), execOpts = {
                    cwd: path.resolve(__dirname, '..'),
                    stdio: 'inherit'
                };
                execa.sync('webtorrent', execArgs, execOpts);
                return [2 /*return*/];
            });
        });