Get publish script working on Windows/node 20

Part of #5135
This commit is contained in:
Daniel Imms
2024-08-31 06:59:34 -07:00
parent cb3bd463a5
commit 6b54599ca7
+8 -2
View File
@@ -9,7 +9,9 @@ const os = require('os');
const path = require('path');
// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
if (process.env['NPM_AUTH_TOKEN']) {
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
}
const isDryRun = process.argv.includes('--dry');
if (isDryRun) {
@@ -118,7 +120,11 @@ function asArray(value) {
}
function getPublishedVersions(packageJson, version, tag) {
const versionsProcess = cp.spawnSync(os.platform === 'win32' ? 'npm.cmd' : 'npm', ['view', packageJson.name, 'versions', '--json']);
const versionsProcess = cp.spawnSync(
os.platform === 'win32' ? 'npm.cmd' : 'npm',
['view', packageJson.name, 'versions', '--json'],
{ shell: true }
);
if (versionsProcess.stdout.length === 0 && versionsProcess.stderr) {
const err = versionsProcess.stderr.toString();
if (err.indexOf('404 Not Found - GET https://registry.npmjs.org/@xterm') > 0) {