Skip to content

Commit

Permalink
Get publish script working on Windows/node 20
Browse files Browse the repository at this point in the history
Part of #5135
  • Loading branch information
Tyriar committed Aug 31, 2024
1 parent cb3bd46 commit 6b54599
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6b54599

Please sign in to comment.