Skip to content

Commit 6b54599

Browse files
committed
Get publish script working on Windows/node 20
Part of #5135
1 parent cb3bd46 commit 6b54599

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bin/publish.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const os = require('os');
99
const path = require('path');
1010

1111
// Setup auth
12-
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
12+
if (process.env['NPM_AUTH_TOKEN']) {
13+
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
14+
}
1315

1416
const isDryRun = process.argv.includes('--dry');
1517
if (isDryRun) {
@@ -118,7 +120,11 @@ function asArray(value) {
118120
}
119121

120122
function getPublishedVersions(packageJson, version, tag) {
121-
const versionsProcess = cp.spawnSync(os.platform === 'win32' ? 'npm.cmd' : 'npm', ['view', packageJson.name, 'versions', '--json']);
123+
const versionsProcess = cp.spawnSync(
124+
os.platform === 'win32' ? 'npm.cmd' : 'npm',
125+
['view', packageJson.name, 'versions', '--json'],
126+
{ shell: true }
127+
);
122128
if (versionsProcess.stdout.length === 0 && versionsProcess.stderr) {
123129
const err = versionsProcess.stderr.toString();
124130
if (err.indexOf('404 Not Found - GET https://registry.npmjs.org/@xterm') > 0) {

0 commit comments

Comments
 (0)