Skip to content

Commit 2432eb0

Browse files
committed
fix: always attempt to set the legacy token env var
Any npm command, include `npm version` attempts to exapand the `LEGACY_TOKEN` environment varialbe if it is set in `.npmrc`.
1 parent e8fe729 commit 2432eb0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ async function verifyConditions(pluginConfig, context) {
2323

2424
const errors = verifyNpmConfig(pluginConfig);
2525

26+
setLegacyToken(context);
27+
2628
try {
2729
const pkg = await getPkg(pluginConfig, context);
2830

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

48+
setLegacyToken(context);
49+
4750
try {
4851
// Reload package.json in case a previous external step updated it
4952
pkg = await getPkg(pluginConfig, context);
5053
if (!verified && pluginConfig.npmPublish !== false && pkg.private !== true) {
51-
setLegacyToken(context);
5254
await verifyNpmAuth(pluginConfig, pkg, context);
5355
}
5456
} catch (error) {

test/integration.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ test('Skip npm auth verification if "package.private" is true', async t => {
6565
{npmPublish: false},
6666
{
6767
cwd,
68+
env: {},
6869
options: {publish: ['@semantic-release/npm']},
6970
stdout: t.context.stdout,
7071
stderr: t.context.stderr,
@@ -83,6 +84,7 @@ test('Skip npm token verification if "package.private" is true', async t => {
8384
{},
8485
{
8586
cwd,
87+
env: {},
8688
options: {publish: ['@semantic-release/npm']},
8789
stdout: t.context.stdout,
8890
stderr: t.context.stderr,

0 commit comments

Comments
 (0)