From f899fa9a7cd7514d2b18f2f4dd2873be193d767e Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2020 12:27:57 +0000 Subject: [PATCH] chore(package): update xo to version 0.28.1 Closes #1488 --- cli.js | 6 +-- index.js | 4 +- lib/branches/index.js | 2 +- lib/definitions/errors.js | 3 +- lib/definitions/plugins.js | 2 +- lib/get-config.js | 14 +++--- lib/git.js | 84 +++++++++++++++++------------------ lib/plugins/index.js | 8 ++-- lib/utils.js | 10 ++--- package.json | 7 ++- test/cli.test.js | 8 ++-- test/git.test.js | 12 ++--- test/helpers/git-utils.js | 70 +++++++++++++++-------------- test/plugins/pipeline.test.js | 2 +- 14 files changed, 120 insertions(+), 112 deletions(-) diff --git a/cli.js b/cli.js index 58c14bc4..1b07fc6a 100755 --- a/cli.js +++ b/cli.js @@ -41,18 +41,18 @@ Usage: .exitProcess(false); try { - const {help, version, ...opts} = cli.parse(argv.slice(2)); + const {help, version, ...options} = cli.parse(argv.slice(2)); if (Boolean(help) || Boolean(version)) { return 0; } - if (opts.debug) { + if (options.debug) { // Debug must be enabled before other requires in order to work require('debug').enable('semantic-release:*'); } - await require('.')(opts); + await require('.')(options); return 0; } catch (error) { if (error.name !== 'YError') { diff --git a/index.js b/index.js index 9959f92f..6051decf 100644 --- a/index.js +++ b/index.js @@ -238,7 +238,7 @@ async function callFail(context, plugins, err) { } } -module.exports = async (opts = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => { +module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => { const {unhook} = hookStd( {silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)}, hideSensitive(env) @@ -253,7 +253,7 @@ module.exports = async (opts = {}, {cwd = process.cwd(), env = process.env, stdo context.logger = getLogger(context); context.logger.log(`Running ${pkg.name} version ${pkg.version}`); try { - const {plugins, options} = await getConfig(context, opts); + const {plugins, options} = await getConfig(context, cliOptions); context.options = options; try { const result = await run(context, plugins); diff --git a/lib/branches/index.js b/lib/branches/index.js index 8bedfe69..f8386d1a 100644 --- a/lib/branches/index.js +++ b/lib/branches/index.js @@ -50,7 +50,7 @@ module.exports = async (repositoryUrl, ciBranch, context) => { const duplicates = [...branches] .map(branch => branch.name) .sort() - .filter((_, idx, arr) => arr[idx] === arr[idx + 1] && arr[idx] !== arr[idx - 1]); + .filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]); if (duplicates.length > 0) { errors.push(getError('EDUPLICATEBRANCHES', {duplicates})); diff --git a/lib/definitions/errors.js b/lib/definitions/errors.js index 553df332..a9554b36 100644 --- a/lib/definitions/errors.js +++ b/lib/definitions/errors.js @@ -4,7 +4,8 @@ const pkg = require('../../package.json'); const {RELEASE_TYPE} = require('./constants'); const [homepage] = pkg.homepage.split('#'); -const stringify = obj => (isString(obj) ? obj : inspect(obj, {breakLength: Infinity, depth: 2, maxArrayLength: 5})); +const stringify = object => + isString(object) ? object : inspect(object, {breakLength: Infinity, depth: 2, maxArrayLength: 5}); const linkify = file => `${homepage}/blob/master/${file}`; const wordsList = words => `${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`; diff --git a/lib/definitions/plugins.js b/lib/definitions/plugins.js index 31407ab8..0da07869 100644 --- a/lib/definitions/plugins.js +++ b/lib/definitions/plugins.js @@ -19,7 +19,7 @@ module.exports = { outputValidator: output => !output || RELEASE_TYPE.includes(output), preprocess: ({commits, ...inputs}) => ({ ...inputs, - commits: commits.filter(commit => !/\[skip\s+release\]|\[release\s+skip\]/i.test(commit.message)), + commits: commits.filter(commit => !/\[skip\s+release]|\[release\s+skip]/i.test(commit.message)), }), postprocess: results => RELEASE_TYPE[ diff --git a/lib/get-config.js b/lib/get-config.js index e80a9f88..d8e54589 100644 --- a/lib/get-config.js +++ b/lib/get-config.js @@ -19,14 +19,14 @@ const CONFIG_FILES = [ `${CONFIG_NAME}.config.js`, ]; -module.exports = async (context, opts) => { +module.exports = async (context, cliOptions) => { const {cwd, env} = context; const {config, filepath} = (await cosmiconfig(CONFIG_NAME, {searchPlaces: CONFIG_FILES}).search(cwd)) || {}; debug('load config from: %s', filepath); // Merge config file options and CLI/API options - let options = {...config, ...opts}; + let options = {...config, ...cliOptions}; if (options.ci === false) { options.noCi = true; } @@ -38,11 +38,11 @@ module.exports = async (context, opts) => { // If `extends` is defined, load and merge each shareable config with `options` options = { ...castArray(extendPaths).reduce((result, extendPath) => { - const extendsOpts = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath)); + const extendsOptions = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath)); // For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path, // so those plugin will be loaded relatively to the config file - Object.entries(extendsOpts) + Object.entries(extendsOptions) .filter(([, value]) => Boolean(value)) .reduce((pluginsPath, [option, value]) => { castArray(value).forEach(plugin => { @@ -58,7 +58,7 @@ module.exports = async (context, opts) => { return pluginsPath; }, pluginsPath); - return {...result, ...extendsOpts}; + return {...result, ...extendsOptions}; }, {}), ...options, }; @@ -92,7 +92,7 @@ module.exports = async (context, opts) => { return {options, plugins: await plugins({...context, options}, pluginsPath)}; }; -async function pkgRepoUrl(opts) { - const {packageJson} = (await readPkgUp(opts)) || {}; +async function pkgRepoUrl(options) { + const {packageJson} = (await readPkgUp(options)) || {}; return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository); } diff --git a/lib/git.js b/lib/git.js index 97a3c99d..c8b0bee4 100644 --- a/lib/git.js +++ b/lib/git.js @@ -14,8 +14,8 @@ Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', commi * * @return {String} The commit sha of the tag in parameter or `null`. */ -async function getTagHead(tagName, execaOpts) { - return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; +async function getTagHead(tagName, execaOptions) { + return (await execa('git', ['rev-list', '-1', tagName], execaOptions)).stdout; } /** @@ -27,8 +27,8 @@ async function getTagHead(tagName, execaOpts) { * @return {Array} List of git tags. * @throws {Error} If the `git` command fails. */ -async function getTags(branch, execaOpts) { - return (await execa('git', ['tag', '--merged', branch], execaOpts)).stdout +async function getTags(branch, execaOptions) { + return (await execa('git', ['tag', '--merged', branch], execaOptions)).stdout .split('\n') .map(tag => tag.trim()) .filter(Boolean); @@ -42,12 +42,12 @@ async function getTags(branch, execaOpts) { * @param {Object} [execaOpts] Options to pass to `execa`. * @return {Promise>} The list of commits between `from` and `to`. */ -async function getCommits(from, to, execaOpts) { +async function getCommits(from, to, execaOptions) { return ( await getStream.array( gitLogParser.parse( {_: `${from ? from + '..' : ''}${to}`}, - {cwd: execaOpts.cwd, env: {...process.env, ...execaOpts.env}} + {cwd: execaOptions.cwd, env: {...process.env, ...execaOptions.env}} ) ) ).map(({message, gitTags, ...commit}) => ({...commit, message: message.trim(), gitTags: gitTags.trim()})); @@ -62,8 +62,8 @@ async function getCommits(from, to, execaOpts) { * @return {Array} List of git branches. * @throws {Error} If the `git` command fails. */ -async function getBranches(repositoryUrl, execaOpts) { - return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOpts)).stdout +async function getBranches(repositoryUrl, execaOptions) { + return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOptions)).stdout .split('\n') .filter(Boolean) .map(branch => branch.match(/^.+refs\/heads\/(?.+)$/)[1]); @@ -77,9 +77,9 @@ async function getBranches(repositoryUrl, execaOpts) { * * @return {Boolean} `true` if the reference exists, falsy otherwise. */ -async function isRefExists(ref, execaOpts) { +async function isRefExists(ref, execaOptions) { try { - return (await execa('git', ['rev-parse', '--verify', ref], execaOpts)).exitCode === 0; + return (await execa('git', ['rev-parse', '--verify', ref], execaOptions)).exitCode === 0; } catch (error) { debug(error); } @@ -99,9 +99,9 @@ async function isRefExists(ref, execaOpts) { * @param {String} branch The repository branch to fetch. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function fetch(repositoryUrl, branch, ciBranch, execaOpts) { +async function fetch(repositoryUrl, branch, ciBranch, execaOptions) { const isDetachedHead = - (await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {...execaOpts, reject: false})).stdout === 'HEAD'; + (await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {...execaOptions, reject: false})).stdout === 'HEAD'; try { await execa( @@ -114,7 +114,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOpts) { ? [repositoryUrl] : ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]), ], - execaOpts + execaOptions ); } catch (_) { await execa( @@ -126,7 +126,7 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOpts) { ? [repositoryUrl] : ['--update-head-ok', repositoryUrl, `+refs/heads/${branch}:refs/heads/${branch}`]), ], - execaOpts + execaOptions ); } } @@ -137,16 +137,16 @@ async function fetch(repositoryUrl, branch, ciBranch, execaOpts) { * @param {String} repositoryUrl The remote repository URL. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function fetchNotes(repositoryUrl, execaOpts) { +async function fetchNotes(repositoryUrl, execaOptions) { try { await execa( 'git', ['fetch', '--unshallow', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], - execaOpts + execaOptions ); } catch (_) { await execa('git', ['fetch', repositoryUrl, `+refs/notes/${GIT_NOTE_REF}:refs/notes/${GIT_NOTE_REF}`], { - ...execaOpts, + ...execaOptions, reject: false, }); } @@ -159,8 +159,8 @@ async function fetchNotes(repositoryUrl, execaOpts) { * * @return {String} the sha of the HEAD commit. */ -async function getGitHead(execaOpts) { - return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; +async function getGitHead(execaOptions) { + return (await execa('git', ['rev-parse', 'HEAD'], execaOptions)).stdout; } /** @@ -170,9 +170,9 @@ async function getGitHead(execaOpts) { * * @return {string} The value of the remote git URL. */ -async function repoUrl(execaOpts) { +async function repoUrl(execaOptions) { try { - return (await execa('git', ['config', '--get', 'remote.origin.url'], execaOpts)).stdout; + return (await execa('git', ['config', '--get', 'remote.origin.url'], execaOptions)).stdout; } catch (error) { debug(error); } @@ -185,9 +185,9 @@ async function repoUrl(execaOpts) { * * @return {Boolean} `true` if the current working directory is in a git repository, falsy otherwise. */ -async function isGitRepo(execaOpts) { +async function isGitRepo(execaOptions) { try { - return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).exitCode === 0; + return (await execa('git', ['rev-parse', '--git-dir'], execaOptions)).exitCode === 0; } catch (error) { debug(error); } @@ -202,9 +202,9 @@ async function isGitRepo(execaOpts) { * * @throws {Error} if not authorized to push. */ -async function verifyAuth(repositoryUrl, branch, execaOpts) { +async function verifyAuth(repositoryUrl, branch, execaOptions) { try { - await execa('git', ['push', '--dry-run', '--no-verify', repositoryUrl, `HEAD:${branch}`], execaOpts); + await execa('git', ['push', '--dry-run', '--no-verify', repositoryUrl, `HEAD:${branch}`], execaOptions); } catch (error) { debug(error); throw error; @@ -220,8 +220,8 @@ async function verifyAuth(repositoryUrl, branch, execaOpts) { * * @throws {Error} if the tag creation failed. */ -async function tag(tagName, ref, execaOpts) { - await execa('git', ['tag', tagName, ref], execaOpts); +async function tag(tagName, ref, execaOptions) { + await execa('git', ['tag', tagName, ref], execaOptions); } /** @@ -232,8 +232,8 @@ async function tag(tagName, ref, execaOpts) { * * @throws {Error} if the push failed. */ -async function push(repositoryUrl, execaOpts) { - await execa('git', ['push', '--tags', repositoryUrl], execaOpts); +async function push(repositoryUrl, execaOptions) { + await execa('git', ['push', '--tags', repositoryUrl], execaOptions); } /** @@ -244,8 +244,8 @@ async function push(repositoryUrl, execaOpts) { * * @throws {Error} if the push failed. */ -async function pushNotes(repositoryUrl, execaOpts) { - await execa('git', ['push', repositoryUrl, `refs/notes/${GIT_NOTE_REF}`], execaOpts); +async function pushNotes(repositoryUrl, execaOptions) { + await execa('git', ['push', repositoryUrl, `refs/notes/${GIT_NOTE_REF}`], execaOptions); } /** @@ -256,9 +256,9 @@ async function pushNotes(repositoryUrl, execaOpts) { * * @return {Boolean} `true` if valid, falsy otherwise. */ -async function verifyTagName(tagName, execaOpts) { +async function verifyTagName(tagName, execaOptions) { try { - return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).exitCode === 0; + return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOptions)).exitCode === 0; } catch (error) { debug(error); } @@ -272,9 +272,9 @@ async function verifyTagName(tagName, execaOpts) { * * @return {Boolean} `true` if valid, falsy otherwise. */ -async function verifyBranchName(branch, execaOpts) { +async function verifyBranchName(branch, execaOptions) { try { - return (await execa('git', ['check-ref-format', `refs/heads/${branch}`], execaOpts)).exitCode === 0; + return (await execa('git', ['check-ref-format', `refs/heads/${branch}`], execaOptions)).exitCode === 0; } catch (error) { debug(error); } @@ -289,10 +289,10 @@ async function verifyBranchName(branch, execaOpts) { * * @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise. */ -async function isBranchUpToDate(repositoryUrl, branch, execaOpts) { +async function isBranchUpToDate(repositoryUrl, branch, execaOptions) { return ( - (await getGitHead(execaOpts)) === - (await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOpts)).stdout.match(/^(?\w+)?/)[1] + (await getGitHead(execaOptions)) === + (await execa('git', ['ls-remote', '--heads', repositoryUrl, branch], execaOptions)).stdout.match(/^(?\w+)?/)[1] ); } @@ -304,9 +304,9 @@ async function isBranchUpToDate(repositoryUrl, branch, execaOpts) { * * @return {Object} the parsed JSON note if there is one, an empty object otherwise. */ -async function getNote(ref, execaOpts) { +async function getNote(ref, execaOptions) { try { - return JSON.parse((await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOpts)).stdout); + return JSON.parse((await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout); } catch (error) { if (error.exitCode === 1) { return {}; @@ -324,8 +324,8 @@ async function getNote(ref, execaOpts) { * @param {String} ref The Git reference to add the note to. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function addNote(note, ref, execaOpts) { - await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOpts); +async function addNote(note, ref, execaOptions) { + await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOptions); } module.exports = { diff --git a/lib/plugins/index.js b/lib/plugins/index.js index 51b080d1..06e50b46 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -46,10 +46,10 @@ module.exports = (context, pluginsPath) => { const pluginsConf = Object.entries(PLUGINS_DEFINITIONS).reduce( (pluginsConf, [type, {required, default: def, pipelineConfig, postprocess = identity, preprocess = identity}]) => { - let pluginOpts; + let pluginOptions; if (isNil(options[type]) && def) { - pluginOpts = def; + pluginOptions = def; } else { // If an object is passed and the path is missing, merge it with step options if (isPlainObject(options[type]) && !options[type].path) { @@ -63,10 +63,10 @@ module.exports = (context, pluginsPath) => { return pluginsConf; } - pluginOpts = options[type]; + pluginOptions = options[type]; } - const steps = castArray(pluginOpts).map(pluginOpt => + const steps = castArray(pluginOptions).map(pluginOpt => normalize( {...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), 'plugins')}, type, diff --git a/lib/utils.js b/lib/utils.js index 14d9d028..ba89e002 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -8,13 +8,13 @@ function extractErrors(err) { function hideSensitiveValues(env, objs) { const hideFunction = hideSensitive(env); - return objs.map(obj => { - Object.getOwnPropertyNames(obj).forEach(prop => { - if (obj[prop]) { - obj[prop] = hideFunction(obj[prop]); + return objs.map(object => { + Object.getOwnPropertyNames(object).forEach(prop => { + if (object[prop]) { + object[prop] = hideFunction(object[prop]); } }); - return obj; + return object; }); } diff --git a/package.json b/package.json index 683fe47c..bcfb4f70 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "sinon": "^9.0.0", "stream-buffers": "^3.0.2", "tempy": "^0.5.0", - "xo": "^0.27.0" + "xo": "^0.28.1" }, "engines": { "node": ">=10.18" @@ -126,6 +126,9 @@ }, "xo": { "prettier": true, - "space": true + "space": true, + "rules": { + "unicorn/string-content": "off" + } } } diff --git a/test/cli.test.js b/test/cli.test.js index 0a198122..fcd5dae6 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -7,11 +7,11 @@ const {SECRET_REPLACEMENT} = require('../lib/definitions/constants'); test.beforeEach(t => { t.context.logs = ''; t.context.errors = ''; - t.context.stdout = stub(process.stdout, 'write').callsFake(val => { - t.context.logs += val.toString(); + t.context.stdout = stub(process.stdout, 'write').callsFake(value => { + t.context.logs += value.toString(); }); - t.context.stderr = stub(process.stderr, 'write').callsFake(val => { - t.context.errors += val.toString(); + t.context.stderr = stub(process.stderr, 'write').callsFake(value => { + t.context.errors += value.toString(); }); }); diff --git a/test/git.test.js b/test/git.test.js index 3454f956..f7bf8725 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -250,9 +250,9 @@ test('Push tag to remote repository with remote branch ahead', async t => { const {cwd, repositoryUrl} = await gitRepo(true); const commits = await gitCommits(['First'], {cwd}); await gitPush(repositoryUrl, 'master', {cwd}); - const tmpRepo = await gitShallowClone(repositoryUrl); - await gitCommits(['Second'], {cwd: tmpRepo}); - await gitPush('origin', 'master', {cwd: tmpRepo}); + const temporaryRepo = await gitShallowClone(repositoryUrl); + await gitCommits(['Second'], {cwd: temporaryRepo}); + await gitPush('origin', 'master', {cwd: temporaryRepo}); await tag('tag_name', 'HEAD', {cwd}); await push(repositoryUrl, {cwd}); @@ -309,9 +309,9 @@ test('Return falsy if repository is not up to date', async t => { t.true(await isBranchUpToDate(repositoryUrl, 'master', {cwd})); - const tmpRepo = await gitShallowClone(repositoryUrl); - await gitCommits(['Third'], {cwd: tmpRepo}); - await gitPush('origin', 'master', {cwd: tmpRepo}); + const temporaryRepo = await gitShallowClone(repositoryUrl); + await gitCommits(['Third'], {cwd: temporaryRepo}); + await gitPush('origin', 'master', {cwd: temporaryRepo}); t.falsy(await isBranchUpToDate(repositoryUrl, 'master', {cwd})); }); diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index cfe47dc4..9b67f68e 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -82,12 +82,13 @@ async function initBareRepo(repositoryUrl, branch = 'master') { * * @returns {Array} The created commits, in reverse order (to match `git log` order). */ -async function gitCommits(messages, execaOpts) { +async function gitCommits(messages, execaOptions) { await pEachSeries( messages, - async message => (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout + async message => + (await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOptions)).stdout ); - return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length); + return (await gitGetCommits(undefined, execaOptions)).slice(0, messages.length); } /** @@ -98,11 +99,14 @@ async function gitCommits(messages, execaOpts) { * * @return {Array} The list of parsed commits. */ -async function gitGetCommits(from, execaOpts) { +async function gitGetCommits(from, execaOptions) { Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}}); return ( await getStream.array( - gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}}) + gitLogParser.parse( + {_: `${from ? from + '..' : ''}HEAD`}, + {...execaOptions, env: {...process.env, ...execaOptions.env}} + ) ) ).map(commit => { commit.message = commit.message.trim(); @@ -118,8 +122,8 @@ async function gitGetCommits(from, execaOpts) { * @param {Boolean} create to create the branch, `false` to checkout an existing branch. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitCheckout(branch, create, execaOpts) { - await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOpts); +async function gitCheckout(branch, create, execaOptions) { + await execa('git', create ? ['checkout', '-b', branch] : ['checkout', branch], execaOptions); } /** @@ -128,8 +132,8 @@ async function gitCheckout(branch, create, execaOpts) { * @param {String} repositoryUrl The repository remote URL. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitFetch(repositoryUrl, execaOpts) { - await execa('git', ['fetch', repositoryUrl], execaOpts); +async function gitFetch(repositoryUrl, execaOptions) { + await execa('git', ['fetch', repositoryUrl], execaOptions); } /** @@ -139,8 +143,8 @@ async function gitFetch(repositoryUrl, execaOpts) { * * @return {String} The sha of the head commit in the current git repository. */ -async function gitHead(execaOpts) { - return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; +async function gitHead(execaOptions) { + return (await execa('git', ['rev-parse', 'HEAD'], execaOptions)).stdout; } /** @@ -150,8 +154,8 @@ async function gitHead(execaOpts) { * @param {String} [sha] The commit on which to create the tag. If undefined the tag is created on the last commit. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitTagVersion(tagName, sha, execaOpts) { - await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOpts); +async function gitTagVersion(tagName, sha, execaOptions) { + await execa('git', sha ? ['tag', '-f', tagName, sha] : ['tag', tagName], execaOptions); } /** @@ -207,8 +211,8 @@ async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) { * @param {String} value Config value. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitAddConfig(name, value, execaOpts) { - await execa('git', ['config', '--add', name, value], execaOpts); +async function gitAddConfig(name, value, execaOptions) { + await execa('git', ['config', '--add', name, value], execaOptions); } /** @@ -219,8 +223,8 @@ async function gitAddConfig(name, value, execaOpts) { * * @return {String} The sha of the commit associated with `tagName` on the local repository. */ -async function gitTagHead(tagName, execaOpts) { - return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; +async function gitTagHead(tagName, execaOptions) { + return (await execa('git', ['rev-list', '-1', tagName], execaOptions)).stdout; } /** @@ -232,8 +236,8 @@ async function gitTagHead(tagName, execaOpts) { * * @return {String} The sha of the commit associated with `tagName` on the remote repository. */ -async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { - return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)).stdout +async function gitRemoteTagHead(repositoryUrl, tagName, execaOptions) { + return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOptions)).stdout .split('\n') .filter(tag => Boolean(tag)) .map(tag => tag.match(/^(?\S+)/)[1])[0]; @@ -247,8 +251,8 @@ async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { * * @return {String} The tag associatedwith the sha in parameter or `null`. */ -async function gitCommitTag(gitHead, execaOpts) { - return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts)).stdout; +async function gitCommitTag(gitHead, execaOptions) { + return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOptions)).stdout; } /** @@ -260,8 +264,8 @@ async function gitCommitTag(gitHead, execaOpts) { * * @throws {Error} if the push failed. */ -async function gitPush(repositoryUrl, branch, execaOpts) { - await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOpts); +async function gitPush(repositoryUrl, branch, execaOptions) { + await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`], execaOptions); } /** @@ -270,8 +274,8 @@ async function gitPush(repositoryUrl, branch, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function merge(ref, execaOpts) { - await execa('git', ['merge', '--no-ff', ref], execaOpts); +async function merge(ref, execaOptions) { + await execa('git', ['merge', '--no-ff', ref], execaOptions); } /** @@ -280,8 +284,8 @@ async function merge(ref, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function mergeFf(ref, execaOpts) { - await execa('git', ['merge', '--ff', ref], execaOpts); +async function mergeFf(ref, execaOptions) { + await execa('git', ['merge', '--ff', ref], execaOptions); } /** @@ -290,8 +294,8 @@ async function mergeFf(ref, execaOpts) { * @param {String} ref The ref to merge. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function rebase(ref, execaOpts) { - await execa('git', ['rebase', ref], execaOpts); +async function rebase(ref, execaOptions) { + await execa('git', ['rebase', ref], execaOptions); } /** @@ -301,8 +305,8 @@ async function rebase(ref, execaOpts) { * @param {String} ref The ref to add the note to. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitAddNote(note, ref, execaOpts) { - await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-m', note, ref], execaOpts); +async function gitAddNote(note, ref, execaOptions) { + await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-m', note, ref], execaOptions); } /** @@ -311,8 +315,8 @@ async function gitAddNote(note, ref, execaOpts) { * @param {String} ref The ref to get the note from. * @param {Object} [execaOpts] Options to pass to `execa`. */ -async function gitGetNote(ref, execaOpts) { - return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOpts)).stdout; +async function gitGetNote(ref, execaOptions) { + return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout; } module.exports = { diff --git a/test/plugins/pipeline.test.js b/test/plugins/pipeline.test.js index 5100b5bf..2d7a9ecf 100644 --- a/test/plugins/pipeline.test.js +++ b/test/plugins/pipeline.test.js @@ -161,7 +161,7 @@ test('Execute each function in series passing a transformed input even if a step const step2 = stub().rejects(error2); const step3 = stub().rejects(error3); const step4 = stub().resolves(4); - const getNextInput = (prevResult, result) => prevResult + result; + const getNextInput = (previousResult, result) => previousResult + result; const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0));