diff --git a/index.js b/index.js index ca618672..621ea9db 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ async function run(options, plugins) { options.repositoryUrl = await getGitAuthUrl(options); - if (!await isBranchUpToDate(options.branch)) { + if (!(await isBranchUpToDate(options.branch))) { logger.log( "The local branch %s is behind the remote one, therefore a new version won't be published.", options.branch diff --git a/lib/get-last-release.js b/lib/get-last-release.js index 9c65588e..1d8fdecf 100644 --- a/lib/get-last-release.js +++ b/lib/get-last-release.js @@ -20,6 +20,7 @@ const {gitTags, isRefInHistory, gitTagHead} = require('./git'); * - Sort the versions * - Retrive the highest version * + * @param {String} tagFormat Git tag format. * @param {Object} logger Global logger. * @return {Promise} The last tagged release or `undefined` if none is found. */ diff --git a/lib/plugins/normalize.js b/lib/plugins/normalize.js index bf71bffa..42c55226 100644 --- a/lib/plugins/normalize.js +++ b/lib/plugins/normalize.js @@ -37,21 +37,20 @@ module.exports = (pluginType, pluginsPath, globalOpts, pluginOpts, logger) => { throw getError('EPLUGIN', {pluginType, pluginName}); } - return Object.defineProperty( - async input => { - const definition = PLUGINS_DEFINITIONS[pluginType]; - try { - const result = await func(cloneDeep(input)); - if (definition && definition.output && !definition.output.validator(result)) { - throw getError(PLUGINS_DEFINITIONS[pluginType].output.error, {result, pluginName}); - } - return result; - } catch (err) { - extractErrors(err).forEach(err => Object.assign(err, {pluginName})); - throw err; + const validator = async input => { + const definition = PLUGINS_DEFINITIONS[pluginType]; + try { + const result = await func(cloneDeep(input)); + if (definition && definition.output && !definition.output.validator(result)) { + throw getError(PLUGINS_DEFINITIONS[pluginType].output.error, {result, pluginName}); } - }, - 'pluginName', - {value: pluginName, writable: false, enumerable: true} - ); + return result; + } catch (err) { + extractErrors(err).forEach(err => Object.assign(err, {pluginName})); + throw err; + } + }; + + Reflect.defineProperty(validator, 'pluginName', {value: pluginName, writable: false, enumerable: true}); + return validator; }; diff --git a/lib/verify.js b/lib/verify.js index 2704d10c..5015ed9d 100644 --- a/lib/verify.js +++ b/lib/verify.js @@ -6,14 +6,14 @@ const getError = require('./get-error'); module.exports = async options => { const errors = []; - if (!await isGitRepo()) { + if (!(await isGitRepo())) { errors.push(getError('ENOGITREPO')); } else if (!options.repositoryUrl) { errors.push(getError('ENOREPOURL')); } // Verify that compiling the `tagFormat` produce a valid Git tag - if (!await verifyTagName(template(options.tagFormat)({version: '0.0.0'}))) { + if (!(await verifyTagName(template(options.tagFormat)({version: '0.0.0'})))) { errors.push(getError('EINVALIDTAGFORMAT', {tagFormat: options.tagFormat})); } diff --git a/package.json b/package.json index 8a1e7885..4d8ea896 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "proxyquire": "^2.0.0", "sinon": "^5.0.1", "tempy": "^0.2.1", - "xo": "^0.20.0" + "xo": "^0.21.0" }, "engines": { "node": ">=8.3" @@ -104,7 +104,8 @@ "all": true }, "prettier": { - "printWidth": 120 + "printWidth": 120, + "trailingComma": "es5" }, "publishConfig": { "tag": "next" diff --git a/test/cli.test.js b/test/cli.test.js index b03b145e..6946fe8a 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -165,12 +165,12 @@ test.serial('Do not set properties in option for which arg is not in command lin await cli(); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 'ci')); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 'd')); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 'dry-run')); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 'debug')); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 'r')); - t.false(Object.prototype.hasOwnProperty.call(run.args[0][0], 't')); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['ci'])); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['d'])); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['dry-run'])); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['debug'])); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['r'])); + t.false(Reflect.apply(Object.prototype.hasOwnProperty, run.args[0][0], ['t'])); }); test.serial('Set "noCi" options to "true" with "--no-ci"', async t => { diff --git a/test/helpers/git-utils.js b/test/helpers/git-utils.js index 6e496ddc..f80a2584 100644 --- a/test/helpers/git-utils.js +++ b/test/helpers/git-utils.js @@ -20,7 +20,7 @@ import getStream from 'get-stream'; * If `withRemote` is `false`, creates a regular repository and initialize it. Change the current working directory to the repository root. * * @param {Boolean} withRemote `true` to create a shallow clone of a bare repository. - * @param {String} [branc='master'] The branch to initialize. + * @param {String} [branch='master'] The branch to initialize. * @return {String} The path of the clone if `withRemote` is `true`, the path of the repository otherwise. */ export async function gitRepo(withRemote, branch = 'master') { diff --git a/test/helpers/gitbox.js b/test/helpers/gitbox.js index 9f09e865..76c40ad0 100644 --- a/test/helpers/gitbox.js +++ b/test/helpers/gitbox.js @@ -16,8 +16,6 @@ const gitCredential = `${GIT_USERNAME}:${GIT_PASSWORD}`; /** * Download the `gitbox` Docker image, create a new container and start it. - * - * @return {Promise} Promise that resolves when the container is started. */ async function start() { await getStream(await docker.pull(IMAGE)); @@ -39,8 +37,6 @@ async function start() { /** * Stop and remote the `mockserver` Docker container. - * - * @return {Promise} Promise that resolves when the container is stopped. */ async function stop() { await container.stop(); diff --git a/test/helpers/mockserver.js b/test/helpers/mockserver.js index 4e8f0bfa..d9c28e96 100644 --- a/test/helpers/mockserver.js +++ b/test/helpers/mockserver.js @@ -12,8 +12,6 @@ let container; /** * Download the `mockserver` Docker image, create a new container and start it. - * - * @return {Promise} Promise that resolves when the container is started. */ async function start() { await getStream(await docker.pull(IMAGE)); @@ -39,8 +37,6 @@ async function start() { /** * Stop and remote the `mockserver` Docker container. - * - * @return {Promise} Promise that resolves when the container is stopped. */ async function stop() { await container.stop(); diff --git a/test/helpers/npm-registry.js b/test/helpers/npm-registry.js index 00309f00..405c35fd 100644 --- a/test/helpers/npm-registry.js +++ b/test/helpers/npm-registry.js @@ -16,8 +16,6 @@ let container; /** * Download the `npm-docker-couchdb` Docker image, create a new container and start it. - * - * @return {Promise} Promise that resolves when the container is started. */ async function start() { await getStream(await docker.pull(IMAGE)); @@ -69,8 +67,6 @@ const authEnv = { /** * Stop and remote the `npm-docker-couchdb` Docker container. - * - * @return {Promise} Promise that resolves when the container is stopped. */ async function stop() { await container.stop();