-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[DOCS] npm scripts update #729
Conversation
- A continuation of @seanhealy's work PR-URL: #729 Credit: @mikemimik Close: #729 Reviewed-by: @mikemimik
that is not dependent on the operating system or architecture of the | ||
target system, use a `prepublish` script. This includes | ||
tasks such as: | ||
The `"scripts"` property of of your `package.json` file supports a number of built-in scripts and their preset life cycle events as well as arbitrary scripts. These all can be executed by running `npm run-script <stage>` or `npm run <stage>` for short. *Pre* and *post* commands with matching names will be run for those as well (e.g. `premyscript`, `myscript`, `postmyscript`). Scripts from dependencies can be run with `npm explore <pkg> -- npm run <stage>`. |
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.
it might be worth noting that although "test" can be user-defined/overridden, "install" can't be (and probably others, like "publish" etc)?
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.
That's a great point, same with pack
. I'll add a "caveats" section. Does that sound right?
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.
Rather than a caveats section I think what I mean is that we have some shorthands for scripts.
npm run test
-> npm test
npm run start
-> npm start
npm run build
-> npm build
npm run restart
-> npm restart
I can't think of any others, can you @ljharb ?
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.
Shorthands that can be overridden for user scripts would also include version
, but I can't think of any others.
It'd be great to exhaustively list BOTH sets - ie, one list of "shorthand commands that run user scripts when present" and "shorthand commands that ignore user scripts even if present" (noting that they all invoke pre/post scripts)
docs/content/using-npm/scripts.md
Outdated
There are some special life cycle scripts that happen only in certain situations. These scripts happen in addtion to the "pre" and "post" script. | ||
* `prepare`, `prepublish`, `prepublishOnly`, `prepack`, `postpack` | ||
|
||
**prepare** |
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.
it would be helpful to indicate the npm version in which each of these scripts was added inline (not just in the paragraph below, and also including prepack/postpack?)
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 think that's a great idea, that context is missing from this update. prepack
and postpack
are included in the list. Did you mean add the version context to those two script names as well?
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.
Seems only the version information about prepare
was there before. I've included it in here now :D
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.
yes, i have no idea when prepack/postpack/pack was added :-p
- A continuation of @seanhealy's work
83f2241
to
e95987c
Compare
|
- A continuation of @seanhealy's work PR-URL: #729 Credit: @mikemimik Close: #729 Reviewed-by: @mikemimik
|
||
### Life Cycle Scripts | ||
|
||
There are some special life cycle scripts that happen only in certain situations. These scripts happen in addtion to the "pre" and "post" script. |
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.
Typo in 'addtion'.
Can we also improve wording on the "Default Values" section? Just to make it clearer users don't have to explicitly declare a start script in the case of having a sever.js file, for example. |
Closed out by @mikemimik in #729 |
What / Why
This is a continuation of the work that @seanhealy has done. The docs were changed to gatsby with a new styling and the markdown was not rendering correctly. I've simply updated some of the formatting and condensed some sections of information together.
References