fix: respect .npmrc if already present (#30)

* fix: respect .npmrc if already present

* Update dist file

Co-authored-by: mitchellhamilton <mitchell@hamil.town>
This commit is contained in:
Nicola Molinari
2020-05-09 08:03:53 +10:00
committed by GitHub
co-authored by mitchellhamilton
parent e49f223776
commit 6f5135b203
3 changed files with 31 additions and 5 deletions
+10 -4
View File
@@ -85,10 +85,16 @@ import readChangesets from "@changesets/read";
let workspacesByName = new Map(workspaces.map(x => [x.name, x]));
fs.writeFileSync(
`${process.env.HOME}/.npmrc`,
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`
);
let npmrcPath = `${process.env.HOME}/.npmrc`
if (fs.existsSync(npmrcPath)) {
console.log("Found existing .npmrc file");
} else {
console.log("No .npmrc file found, creating one");
fs.writeFileSync(
npmrcPath,
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`
);
}
let [publishCommand, ...publishArgs] = inputs.publishScript.split(/\s+/);