How to use the execa.stdout 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 pikapkg / pack / checkpoint / dist-src / util / publish / prerequisite.js View on Github external
if (!version.isValidVersionInput(options.version)) {
        throw new Error(`Version should be either ${version.SEMVER_INCREMENTS.join(', ')}, or a valid semver version.`);
    }
    newVersion = version.getNewVersion(pkg.version, options.version);
    if (!version.isVersionGreater(pkg.version, newVersion)) {
        throw new Error(`New version \`${newVersion}\` should be higher than current version \`${pkg.version}\``);
    }
    // title: 'Check for pre-release version',
    if (!pkg.private && version.isPrereleaseVersion(newVersion) && !options.tag) {
        throw new Error('You must specify a dist-tag using --tag when publishing a pre-release version. This prevents accidentally tagging unstable versions as "latest". https://docs.npmjs.com/cli/dist-tag');
    }
    // title: 'Check git tag existence',
    await execa('git', ['fetch']);
    const tagPrefix = await getTagVersionPrefix(options);
    try {
        const { stdout: revInfo } = await execa.stdout('git', [
            'rev-parse',
            '--quiet',
            '--verify',
            `refs/tags/${tagPrefix}${newVersion}`,
        ]);
        if (revInfo) {
            throw new Error(`Git tag \`${tagPrefix}${newVersion}\` already exists.`);
        }
    }
    catch (error) {
        // Command fails with code 1 and no output if the tag does not exist, even though `--quiet` is provided
        // https://github.com/sindresorhus/np/pull/73#discussion_r72385685
        if (error.stdout !== '' || error.stderr !== '') {
            throw error;
        }
    }
github DefinitelyTyped / DefinitelyTyped / types / execa / execa-tests.ts View on Github external
execa('foo')
    .catch(error => {
        assert(error.cmd === 'foo');
        assert(error.code === 128);
        assert(error.failed === true);
        assert(error.killed === false);
        assert(error.signal === 'SIGINT');
        assert(error.stderr === 'stderr');
        assert(error.stdout === 'stdout');
        assert(error.timedOut === false);
    });

execa('noop', ['foo'])
    .then(result => result.stderr.toLocaleLowerCase());

execa.stdout('unicorns')
    .then(stdout => stdout.toLocaleLowerCase());
execa.stdout('echo', ['unicorns'])
    .then(stdout => stdout.toLocaleLowerCase());

execa.stderr('unicorns')
    .then(stderr => stderr.toLocaleLowerCase());
execa.stderr('echo', ['unicorns'])
    .then(stderr => stderr.toLocaleLowerCase());

execa.shell('echo unicorns')
    .then(result => result.stdout.toLocaleLowerCase());

{
    let result: string;
    result = execa.shellSync('foo').stderr;
    result = execa.shellSync('noop', { cwd: 'foo' }).stdout;
github sindresorhus / fullname / index.js View on Github external
async function checkGit() {
	const fullName = await execa.stdout('git', [
		'config',
		'--global',
		'user.name'
	]);

	if (!fullName) {
		throw new Error();
	}

	return fullName;
}
github MainframeHQ / onyx / packages / onyx-toolbox / lib / api.js View on Github external
const gitClone = cwd =>
  execa.stdout(
    'git',
    [
      'clone',
      '--branch',
      gitTag,
      '--depth',
      1,
      'https://github.com/MainframeHQ/go-ethereum.git',
    ],
    { cwd },
  )
github elastic / kibana / src / dev / build / lib / version_info.js View on Github external
export async function getVersionInfo({ isRelease, versionQualifier, pkg }) {
  const buildVersion = pkg.version.concat(
    versionQualifier ? `-${versionQualifier}` : '',
    isRelease ? '' : '-SNAPSHOT'
  );

  return {
    buildSha: await execa.stdout('git', ['rev-parse', 'HEAD']),
    buildVersion,
    buildNumber: await getBuildNumber(),
  };
}
github brodybits / prettierx / scripts / release / steps / post-publish-steps.js View on Github external
async function checkSchema() {
  const schema = await execa.stdout("node", ["scripts/generate-schema.js"]);
  const remoteSchema = await logPromise(
    "Checking current schema in SchemaStore",
    fetch(RAW_URL)
      .then(r => r.text())
      .then(t => t.trim())
  );

  if (schema === remoteSchema) {
    return;
  }

  return dedent(chalk`
    {bold.underline The schema in {yellow SchemaStore} needs an update.}
    - Open {cyan.underline ${EDIT_URL}}
    - Run {yellow node scripts/generate-schema.js} and copy the new schema
    - Paste it on GitHub interface
github brodybits / prettierx / scripts / release / steps / install-dependencies.js View on Github external
async function install() {
  await execa("rm", ["-rf", "node_modules"]);
  await execa("yarn", ["install"]);

  const status = await execa.stdout("git", ["ls-files", "-m"]);
  if (status) {
    throw Error(
      "The lockfile needs to be updated, commit it before making the release."
    );
  }
}
github sindresorhus / clipboardy / lib / linux.js View on Github external
const xselWithFallback = async (argumentList, options) => {
	try {
		return await execa.stdout(xsel, argumentList, options);
	} catch (xselError) {
		try {
			return await execa.stdout(xselFallback, argumentList, options);
		} catch (fallbackError) {
			throw makeError(xselError, fallbackError);
		}
	}
};
github GoogleContainerTools / kpt / docsy / node_modules / os-locale / index.js View on Github external
function getAppleLocale() {
	return Promise.all([
		execa.stdout('defaults', ['read', '-globalDomain', 'AppleLocale']),
		getLocales()
	]).then(results => getSupportedLocale(results[0], results[1]));
}
github GoogleContainerTools / kpt / docsy / node_modules / os-locale / index.js View on Github external
function getWinLocale() {
	return execa.stdout('wmic', ['os', 'get', 'locale'])
		.then(stdout => {
			const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
			return lcid.from(lcidCode);
		});
}