-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update index.ts #59
Update index.ts #59
Conversation
Check for `npmrc` in project root first then check in HOME directory. If it's not found at either place then create one in the project root instead of the HOME directory to be on a safer side and not tampering the HOME directory fixes changesets#58
let npmrcPath = `${process.env.HOME}/.npmrc`; | ||
if (fs.existsSync(npmrcPath)) { | ||
let npmrcHomePath = `${process.env.HOME}/.npmrc`; | ||
let npmrcProjectRootPath = `${process.env.PWD}/.npmrc`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any particular reason why you have chosen this over process.cwd()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.env.PWD
is a safer way compared to process.env.cwd()
because while your process is running and if one of the commands in that process changes the working directory while it's still executing the value of process.env.cwd()
will change at all the places where it's being referred. process.env.PWD
guarantees that your current working directory will be set to a path when the command actually started executing and wouldn't change during the lifecycle of the process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general - but I have not been using .npmrc
files much so I'm not super confident myself with merging this, would prefer if @mitchellhamilton would take a look at this first
I'm not sure why we would want to do this? Creating the For the linked issue, won't npm prefer any settings set in the local |
@mitchellhamilton Sure makes sense. I'll make changes and write the |
To be clear, I'm unsure what problem this PR solves since npm should respect config in a local .npmrc over the global .npmrc + not writing the global config if a local config exists could cause problems if people have a local .npmrc with some config committed to their repo(but without auth) |
@mitchellhamilton I've an - name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
[email protected]
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
Hmmmm, I think that'll be because of changesets/changesets#448. I don't think changing what's being changed in this PR would fix that. |
Oh okay alright! maybe I'll close this then. |
Check for
npmrc
in project root first then check in HOME directory. If it's not found at either place then create one in the the HOME directory.fixes #58