Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
}
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;
async function checkGit() {
const fullName = await execa.stdout('git', [
'config',
'--global',
'user.name'
]);
if (!fullName) {
throw new Error();
}
return fullName;
}
const gitClone = cwd =>
execa.stdout(
'git',
[
'clone',
'--branch',
gitTag,
'--depth',
1,
'https://github.com/MainframeHQ/go-ethereum.git',
],
{ cwd },
)
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(),
};
}
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
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."
);
}
}
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);
}
}
};
function getAppleLocale() {
return Promise.all([
execa.stdout('defaults', ['read', '-globalDomain', 'AppleLocale']),
getLocales()
]).then(results => getSupportedLocale(results[0], results[1]));
}
function getWinLocale() {
return execa.stdout('wmic', ['os', 'get', 'locale'])
.then(stdout => {
const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
return lcid.from(lcidCode);
});
}