Skip to content

Commit

Permalink
fix: always attempt to set the legacy token env var
Browse files Browse the repository at this point in the history
Any npm command, include `npm version` attempts to exapand the `LEGACY_TOKEN` environment varialbe if it is set in `.npmrc`.
  • Loading branch information
pvdlg committed Nov 9, 2018
1 parent e8fe729 commit 2432eb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ async function verifyConditions(pluginConfig, context) {

const errors = verifyNpmConfig(pluginConfig);

setLegacyToken(context);

try {
const pkg = await getPkg(pluginConfig, context);

// Verify the npm authentication only if `npmPublish` is not false and `pkg.private` is not `true`
if (pluginConfig.npmPublish !== false && pkg.private !== true) {
setLegacyToken(context);
await verifyNpmAuth(pluginConfig, pkg, context);
}
} catch (error) {
Expand All @@ -44,11 +45,12 @@ async function prepare(pluginConfig, context) {
let pkg;
const errors = verified ? [] : verifyNpmConfig(pluginConfig);

setLegacyToken(context);

try {
// Reload package.json in case a previous external step updated it
pkg = await getPkg(pluginConfig, context);
if (!verified && pluginConfig.npmPublish !== false && pkg.private !== true) {
setLegacyToken(context);
await verifyNpmAuth(pluginConfig, pkg, context);
}
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ test('Skip npm auth verification if "package.private" is true', async t => {
{npmPublish: false},
{
cwd,
env: {},
options: {publish: ['@semantic-release/npm']},
stdout: t.context.stdout,
stderr: t.context.stderr,
Expand All @@ -83,6 +84,7 @@ test('Skip npm token verification if "package.private" is true', async t => {
{},
{
cwd,
env: {},
options: {publish: ['@semantic-release/npm']},
stdout: t.context.stdout,
stderr: t.context.stderr,
Expand Down

0 comments on commit 2432eb0

Please sign in to comment.