Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit c10d0b4

Browse files
Log out npm config and append token to current file
1 parent d83de18 commit c10d0b4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build-scripts/publish.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const path = require('path');
2929
const runCommand = require('./run-command');
3030

3131
const packagesDirPath = path.resolve(__dirname, '../packages');
32-
const npmrcPath = path.resolve(process.env.HOME, '.npmrc');
32+
const npmrcPath = process.env.NPM_CONFIG_USERCONFIG;
3333

3434
async function isPackageVersionPublished(packageName, version) {
3535
return fetch(`https://registry.npmjs.org/${encodeURI(packageName)}/${version}`)
@@ -56,10 +56,11 @@ async function getPackageInfo(packageDir) {
5656

5757
async function setupNpm() {
5858
// For npm publication to work, the NPM token must be stored in the .npmrc file
59+
console.log('Current .npmrc file:\n', await fs.readFile(npmrcPath, 'utf8'));
5960
if (process.env.GITHUB_ACTIONS && process.env.NPM_TOKEN) {
60-
await fs.writeFile(
61+
await fs.appendFile(
6162
npmrcPath,
62-
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\nregistry=https://registry.npmjs.org/`,
63+
`\n//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`,
6364
'utf8');
6465
}
6566
}

0 commit comments

Comments
 (0)