Skip to content

Commit c43b642

Browse files
committed
doc: highlight globs and emphasize double quotes
This adds an "important" callout to emphasize that double quotes are necessary and single quotes won't work. Fixes #213
1 parent 05db932 commit c43b642

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,26 @@ platform-independent scripts, we recommend you go with that.
7171

7272
However, `shx` is ideal for one-liners inside `package.json`:
7373

74-
```javascript
74+
```json
7575
{
7676
"scripts": {
77-
"clean": "shx rm -rf build dist && shx echo Done"
77+
"clean": "shx rm -rf \"build/**/*.js\" \"build/output\" && shx echo \"Done cleaning\""
7878
}
7979
}
8080
```
8181

82-
**Tip:** because Windows treats single quotes (ex. `'some string'`) differently
83-
than double quotes, [we
84-
recommend](https://github.com/shelljs/shx/issues/165#issuecomment-563127983)
85-
wrapping your arguments in double quotes for cross platform compatibility (ex.
86-
`"some string"`).
82+
It's safe to use `&&` and `||` operators in npm package scripts. These will be
83+
interpreted by the operating system's shell (`sh` on Unix, `cmd.exe` on
84+
Windows). If you're using glob operators like `*` or `**`, then we recommend to
85+
**put these in double quotes**, which ensures that `shx` will expand the glob
86+
rather than the operating system shell.
87+
88+
> [!IMPORTANT]
89+
> Windows treats single quotes (ex. `'some string'`) differently than double
90+
> quotes.
91+
> [We recommend](https://github.com/shelljs/shx/issues/165#issuecomment-563127983)
92+
> wrapping your arguments in **escaped double quotes** so that your code is
93+
> compatible cross platform (ex. `"clean": "shx echo \"some string\""`).
8794
8895
## Command reference
8996

0 commit comments

Comments
 (0)