-
Notifications
You must be signed in to change notification settings - Fork 3.4k
docs: Clarify script working directory behavior (fixes #8305) #8308
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
base: latest
Are you sure you want to change the base?
docs: Clarify script working directory behavior (fixes #8305) #8308
Conversation
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.
I like the change in general, just a little cleanup and we'll run the tests on it
In npm v7 and later, scripts are always executed from the root of the package folder, regardless of your current working directory. This behavior is now reliable and consistent. | ||
|
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.
In npm v7 and later, scripts are always executed from the root of the package folder, regardless of your current working directory. This behavior is now reliable and consistent. |
This can be removed, repeat of the above section.
script to use different behavior based on what subdirectory you're in, you | ||
can use the `INIT_CWD` environment variable, which holds the full path you | ||
were in when you ran `npm run`. | ||
|
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.
Extra space
@owlstronaut |
@owlstronaut |
Co-authored-by: Michael Smith <[email protected]>
This pull request updates the documentation for npm scripts, specifically the
scripts.md
file.What:
process.cwd()
could be used as a safeguard.INIT_CWD
environment variable is mentioned as a way for scripts to access the original working directory.Why:
This change aims to provide clearer and more accurate documentation regarding the working directory of npm scripts, addressing potential confusion, especially for users working with or migrating from older npm versions. This helps resolve the points raised in issue #8305.
References
Fixes #8305