mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
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:
co-authored by
mitchellhamilton
parent
e49f223776
commit
6f5135b203
@@ -104,6 +104,26 @@ jobs:
|
||||
|
||||
```
|
||||
|
||||
By default the GitHub Action creates a `.npmrc` file with the following content:
|
||||
|
||||
```
|
||||
//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}
|
||||
```
|
||||
|
||||
However, if a `.npmrc` file is found, the GitHub Action does not recreate the file. This is useful if you need to configure the `.npmrc` file on your own.
|
||||
For example, you can add a step before running the Changesets GitHub Action:
|
||||
|
||||
```yml
|
||||
- name: Creating .npmrc
|
||||
run: |
|
||||
cat << EOF > "$HOME/.npmrc"
|
||||
email=my@email.com
|
||||
//registry.npmjs.org/:_authToken=$NPM_TOKEN
|
||||
EOF
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
```
|
||||
|
||||
#### With version script
|
||||
|
||||
If you need to add additional logic to the version command, you can do so by using a version script.
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -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+/);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user