Skip to content

Commit f40aa32

Browse files
committed
guidance on --
1 parent ab4db7a commit f40aa32

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/npm/index.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,40 @@ Note that commonly the issues are found in *development* dependencies (e.g. jest
5757

5858
Simply add `npm audit` (the command exist with error code `1` in case of error) as a part of your deployment to ensure the projects stay up to date.
5959

60+
## NPM Scripts
61+
62+
### What is with `--` in scripts
63+
You can build a base script with a limited set of command line arguments e.g. here is a script target that runs `tsc` for the TypeScript compiler:
64+
65+
```json
66+
{
67+
"scripts": {
68+
"build": "tsc -p ."
69+
}
70+
}
71+
```
72+
73+
You can create a `build:watch` target to run `tsc -p . -w` or alternatively asking npm to run `build` with the additional `-w` flag like so:
74+
75+
```json
76+
{
77+
"scripts": {
78+
"build": "tsc -p .",
79+
"build:watch": "npm run build -- -w"
80+
}
81+
}
82+
```
83+
You can pass in as many flags as you want after `--` e.g. in the following example `build:more` has the same effect as `something --foo -f -d --bar`
84+
85+
```json
86+
{
87+
"scripts": {
88+
"build": "something --foo",
89+
"build:more": "npm run build -- -f -d --bar"
90+
}
91+
}
92+
```
93+
6094
## Public vs. Private packages
6195
You don't need this when *using* any of the common public npm packages. Just know its there for enterprise / commercial customers.
6296

0 commit comments

Comments
 (0)