diff --git a/index.js b/index.js index e6d41ef9..ceaf2f15 100644 --- a/index.js +++ b/index.js @@ -36,9 +36,11 @@ async function verifyConditions(pluginConfig, context) { } catch (error) { errors.push(...error); } + if (errors.length > 0) { throw new AggregateError(errors); } + verified = true; } @@ -56,9 +58,11 @@ async function prepare(pluginConfig, context) { } catch (error) { errors.push(...error); } + if (errors.length > 0) { throw new AggregateError(errors); } + await prepareNpm(pluginConfig, context); prepared = true; } @@ -78,12 +82,15 @@ async function publish(pluginConfig, context) { } catch (error) { errors.push(...error); } + if (errors.length > 0) { throw new AggregateError(errors); } + if (!prepared) { await prepareNpm(pluginConfig, context); } + return publishNpm(pluginConfig, pkg, context); } diff --git a/lib/definitions/errors.js b/lib/definitions/errors.js index dd70a39f..10a70523 100644 --- a/lib/definitions/errors.js +++ b/lib/definitions/errors.js @@ -1,7 +1,6 @@ -const url = require('url'); const pkg = require('../../package.json'); -const homepage = url.format({...url.parse(pkg.homepage), ...{hash: null}}); +const [homepage] = pkg.homepage.split('#'); const linkify = file => `${homepage}/blob/master/${file}`; module.exports = { diff --git a/lib/set-npmrc-auth.js b/lib/set-npmrc-auth.js index 71fbfa3b..da316845 100644 --- a/lib/set-npmrc-auth.js +++ b/lib/set-npmrc-auth.js @@ -12,6 +12,7 @@ module.exports = async (registry, {cwd, env: {NPM_TOKEN, NPM_USERNAME, NPM_PASSW if (getAuthToken(registry, {npmrc: rc('npm', {registry: 'https://registry.npmjs.org/'}, {config})})) { return; } + if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) { await appendFile(config, `\n_auth = \${LEGACY_TOKEN}\nemail = \${NPM_EMAIL}`); logger.log(`Wrote NPM_USERNAME, NPM_PASSWORD and NPM_EMAIL to ${config}`); diff --git a/package.json b/package.json index 419fa97a..4130a57f 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "sinon": "^7.1.1", "stream-buffers": "^3.0.2", "tempy": "^0.2.1", - "xo": "^0.23.0" + "xo": "^0.24.0" }, "engines": { "node": ">=8.3" diff --git a/test/integration.test.js b/test/integration.test.js index 0f884e9a..e6c6c0f2 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -186,7 +186,7 @@ test('Verify npm auth and package with "npm_config_registry" env var set by yarn {}, { cwd, - env: {...npmRegistry.authEnv, npm_config_registry: 'https://registry.yarnpkg.com'}, // eslint-disable-line camelcase + env: {...npmRegistry.authEnv, npm_config_registry: 'https://registry.yarnpkg.com'}, options: {publish: []}, stdout: t.context.stdout, stderr: t.context.stderr,