chore(package): update xo to version 0.23.0

This commit is contained in:
greenkeeper[bot] 2018-09-03 11:58:07 +00:00 committed by Pierre Vanduynslager
parent 42e9d1192f
commit fa62d427b6
11 changed files with 52 additions and 52 deletions

View File

@ -30,9 +30,9 @@ execa
process.exit(1); process.exit(1);
} }
}) })
.catch(err => { .catch(error => {
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. No git binary found.`); console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. No git binary found.`);
console.error(err); console.error(error);
process.exit(1); process.exit(1);
}); });

6
cli.js
View File

@ -57,9 +57,9 @@ Usage:
} }
await require('.')(opts); await require('.')(opts);
return 0; return 0;
} catch (err) { } catch (error) {
if (err.name !== 'YError') { if (error.name !== 'YError') {
stderr.write(hideSensitive(env)(util.inspect(err, {colors: true}))); stderr.write(hideSensitive(env)(util.inspect(error, {colors: true})));
} }
return 1; return 1;
} }

View File

@ -60,14 +60,14 @@ async function run(context, plugins) {
try { try {
await verifyAuth(options.repositoryUrl, options.branch, {cwd, env}); await verifyAuth(options.repositoryUrl, options.branch, {cwd, env});
} catch (err) { } catch (error) {
if (!(await isBranchUpToDate(options.branch, {cwd, env}))) { if (!(await isBranchUpToDate(options.branch, {cwd, env}))) {
logger.log( logger.log(
`The local branch ${options.branch} is behind the remote one, therefore a new version won't be published.` `The local branch ${options.branch} is behind the remote one, therefore a new version won't be published.`
); );
return false; return false;
} }
logger.error(`The command "${err.cmd}" failed with the error message ${err.stderr}.`); logger.error(`The command "${error.cmd}" failed with the error message ${error.stderr}.`);
throw getError('EGITNOPERMISSION', {options}); throw getError('EGITNOPERMISSION', {options});
} }
@ -131,13 +131,13 @@ function logErrors({logger, stderr}, err) {
} }
} }
async function callFail(context, plugins, error) { async function callFail(context, plugins, err) {
const errors = extractErrors(error).filter(error => error.semanticRelease); const errors = extractErrors(err).filter(err => err.semanticRelease);
if (errors.length > 0) { if (errors.length > 0) {
try { try {
await plugins.fail({...context, errors}); await plugins.fail({...context, errors});
} catch (err) { } catch (error) {
logErrors(context, err); logErrors(context, error);
} }
} }
} }
@ -157,15 +157,15 @@ module.exports = async (opts = {}, {cwd = process.cwd(), env = process.env, stdo
const result = await run(context, plugins); const result = await run(context, plugins);
unhook(); unhook();
return result; return result;
} catch (err) { } catch (error) {
if (!options.dryRun) { if (!options.dryRun) {
await callFail(context, plugins, err); await callFail(context, plugins, error);
} }
throw err; throw error;
} }
} catch (err) { } catch (error) {
logErrors(context, err); logErrors(context, error);
unhook(); unhook();
throw err; throw error;
} }
}; };

View File

@ -43,7 +43,7 @@ module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => {
// Test if push is allowed without transforming the URL (e.g. is ssh keys are set up) // Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
try { try {
await verifyAuth(repositoryUrl, branch, {cwd, env}); await verifyAuth(repositoryUrl, branch, {cwd, env});
} catch (err) { } catch (error) {
const envVar = Object.keys(GIT_TOKENS).find(envVar => !isUndefined(env[envVar])); const envVar = Object.keys(GIT_TOKENS).find(envVar => !isUndefined(env[envVar]));
const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`; const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`;
const {protocols, ...parsed} = gitUrlParse(repositoryUrl); const {protocols, ...parsed} = gitUrlParse(repositoryUrl);

View File

@ -12,8 +12,8 @@ const debug = require('debug')('semantic-release:git');
async function gitTagHead(tagName, execaOpts) { async function gitTagHead(tagName, execaOpts) {
try { try {
return await execa.stdout('git', ['rev-list', '-1', tagName], execaOpts); return await execa.stdout('git', ['rev-list', '-1', tagName], execaOpts);
} catch (err) { } catch (error) {
debug(err); debug(error);
} }
} }
@ -44,13 +44,13 @@ async function isRefInHistory(ref, execaOpts) {
try { try {
await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], execaOpts); await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], execaOpts);
return true; return true;
} catch (err) { } catch (error) {
if (err.code === 1) { if (error.code === 1) {
return false; return false;
} }
debug(err); debug(error);
throw err; throw error;
} }
} }
@ -63,7 +63,7 @@ async function isRefInHistory(ref, execaOpts) {
async function fetch(repositoryUrl, execaOpts) { async function fetch(repositoryUrl, execaOpts) {
try { try {
await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl], execaOpts); await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl], execaOpts);
} catch (err) { } catch (error) {
await execa('git', ['fetch', '--tags', repositoryUrl], execaOpts); await execa('git', ['fetch', '--tags', repositoryUrl], execaOpts);
} }
} }
@ -75,7 +75,7 @@ async function fetch(repositoryUrl, execaOpts) {
* *
* @return {string} the sha of the HEAD commit. * @return {string} the sha of the HEAD commit.
*/ */
async function gitHead(execaOpts) { function gitHead(execaOpts) {
return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts); return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts);
} }
@ -89,8 +89,8 @@ async function gitHead(execaOpts) {
async function repoUrl(execaOpts) { async function repoUrl(execaOpts) {
try { try {
return await execa.stdout('git', ['config', '--get', 'remote.origin.url'], execaOpts); return await execa.stdout('git', ['config', '--get', 'remote.origin.url'], execaOpts);
} catch (err) { } catch (error) {
debug(err); debug(error);
} }
} }
@ -104,8 +104,8 @@ async function repoUrl(execaOpts) {
async function isGitRepo(execaOpts) { async function isGitRepo(execaOpts) {
try { try {
return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).code === 0; return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).code === 0;
} catch (err) { } catch (error) {
debug(err); debug(error);
} }
} }
@ -121,9 +121,9 @@ async function isGitRepo(execaOpts) {
async function verifyAuth(repositoryUrl, branch, execaOpts) { async function verifyAuth(repositoryUrl, branch, execaOpts) {
try { try {
await execa('git', ['push', '--dry-run', repositoryUrl, `HEAD:${branch}`], execaOpts); await execa('git', ['push', '--dry-run', repositoryUrl, `HEAD:${branch}`], execaOpts);
} catch (err) { } catch (error) {
debug(err); debug(error);
throw err; throw error;
} }
} }
@ -163,8 +163,8 @@ async function push(repositoryUrl, branch, execaOpts) {
async function verifyTagName(tagName, execaOpts) { async function verifyTagName(tagName, execaOpts) {
try { try {
return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).code === 0; return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).code === 0;
} catch (err) { } catch (error) {
debug(err); debug(error);
} }
} }
@ -182,8 +182,8 @@ async function isBranchUpToDate(branch, execaOpts) {
(await execa.stdout('git', ['ls-remote', '--heads', 'origin', branch], execaOpts)).match(/^(\w+)?/)[1], (await execa.stdout('git', ['ls-remote', '--heads', 'origin', branch], execaOpts)).match(/^(\w+)?/)[1],
execaOpts execaOpts
); );
} catch (err) { } catch (error) {
debug(err); debug(error);
} }
} }

View File

@ -42,10 +42,10 @@ module.exports = ({cwd, stdout, stderr, options, logger}, type, pluginOpt, plugi
} }
logger.success(`Completed step "${type}" of plugin "${pluginName}"`); logger.success(`Completed step "${type}" of plugin "${pluginName}"`);
return result; return result;
} catch (err) { } catch (error) {
logger.error(`Failed step "${type}" of plugin "${pluginName}"`); logger.error(`Failed step "${type}" of plugin "${pluginName}"`);
extractErrors(err).forEach(err => Object.assign(err, {pluginName})); extractErrors(error).forEach(err => Object.assign(err, {pluginName}));
throw err; throw error;
} }
}; };

View File

@ -36,12 +36,12 @@ module.exports = (steps, {settleAll = false, getNextInput = identity, transform
// Call the step with the input computed at the end of the previous iteration and save intermediary result // Call the step with the input computed at the end of the previous iteration and save intermediary result
result = await transform(await step(lastInput), step, lastInput); result = await transform(await step(lastInput), step, lastInput);
results.push(result); results.push(result);
} catch (err) { } catch (error) {
if (settleAll) { if (settleAll) {
errors.push(...extractErrors(err)); errors.push(...extractErrors(error));
result = err; result = error;
} else { } else {
throw err; throw error;
} }
} }
// Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one // Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one

View File

@ -67,7 +67,7 @@
"sinon": "^6.0.0", "sinon": "^6.0.0",
"stream-buffers": "^3.0.2", "stream-buffers": "^3.0.2",
"tempy": "^0.2.1", "tempy": "^0.2.1",
"xo": "^0.22.0" "xo": "^0.23.0"
}, },
"engines": { "engines": {
"node": ">=8.3" "node": ">=8.3"

View File

@ -69,7 +69,7 @@ export async function initBareRepo(repositoryUrl, branch = 'master') {
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order). * @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
*/ */
export async function gitCommits(messages, execaOpts) { export async function gitCommits(messages, execaOpts) {
await pReduce(messages, async (_, message) => await pReduce(messages, (_, message) =>
execa.stdout('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts) execa.stdout('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)
); );
return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length); return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length);
@ -112,7 +112,7 @@ export async function gitCheckout(branch, create = true, execaOpts) {
* *
* @return {String} The sha of the head commit in the current git repository. * @return {String} The sha of the head commit in the current git repository.
*/ */
export async function gitHead(execaOpts) { export function gitHead(execaOpts) {
return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts); return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts);
} }
@ -181,7 +181,7 @@ export async function gitAddConfig(name, value, execaOpts) {
* *
* @return {String} The sha of the commit associated with `tagName` on the local repository. * @return {String} The sha of the commit associated with `tagName` on the local repository.
*/ */
export async function gitTagHead(tagName, execaOpts) { export function gitTagHead(tagName, execaOpts) {
return execa.stdout('git', ['rev-list', '-1', tagName], execaOpts); return execa.stdout('git', ['rev-list', '-1', tagName], execaOpts);
} }
@ -209,7 +209,7 @@ export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
* *
* @return {String} The tag associatedwith the sha in parameter or `null`. * @return {String} The tag associatedwith the sha in parameter or `null`.
*/ */
export async function gitCommitTag(gitHead, execaOpts) { export function gitCommitTag(gitHead, execaOpts) {
return execa.stdout('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts); return execa.stdout('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts);
} }

View File

@ -30,7 +30,7 @@ async function start() {
minTimeout: 1000, minTimeout: 1000,
factor: 2, factor: 2,
}); });
} catch (err) { } catch (error) {
throw new Error(`Couldn't start mock-server after 2 min`); throw new Error(`Couldn't start mock-server after 2 min`);
} }
} }
@ -96,7 +96,7 @@ async function mock(
* @param {Object} expectation The expectation created with `mock` function. * @param {Object} expectation The expectation created with `mock` function.
* @return {Promise} A Promise that resolves if the expectation is met or reject otherwise. * @return {Promise} A Promise that resolves if the expectation is met or reject otherwise.
*/ */
async function verify(expectation) { function verify(expectation) {
return client.verify(expectation); return client.verify(expectation);
} }

View File

@ -39,7 +39,7 @@ async function start() {
minTimeout: 1000, minTimeout: 1000,
factor: 2, factor: 2,
}); });
} catch (err) { } catch (error) {
throw new Error(`Couldn't start npm-registry-docker after 2 min`); throw new Error(`Couldn't start npm-registry-docker after 2 min`);
} }