Skip to content

Commit

Permalink
docs/cli: Added command caveats for test and run.
Browse files Browse the repository at this point in the history
This documentation clearly informs users that system-wide commands in scripts
do not work like they do in npm.
  • Loading branch information
umamialex committed Oct 12, 2016
1 parent c1bcadf commit a723dc4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions en/docs/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ For example, the following would provide a script named `test` in your package t
"test": "jest"
},
```

If you have used a package manager like npm previously, you might be used to
writing system commands directly:

```json
"scripts": {
"test": "echo \"I promise I'll write tests later.\""
}
```

Running `yarn run test` will result in an error since `echo` is not guaranteed
to be a valid command in all environments. This rule also applies to globally
installed npm packages.
27 changes: 27 additions & 0 deletions en/docs/cli/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,30 @@ Hello, world!
##### `yarn run test`

`yarn test` is also a shortcut for `yarn run test`.

### Caveats

If you have used a package manager like npm previously, you might be used to
writing system commands directly:

```json
"scripts": {
"test": "echo \"I promise I'll write tests later.\""
}
```

Running `yarn test` will result in an error since `echo` is not guaranteed to be
a valid command in all environments. This rule also applies to globally
installed npm packages.

However, locally installed node modules that export an executable command will
work.

For example, if `jest` is installed using `yarn add`, then the following is
valid:

```json
"scripts": {
"test": "jest"
}
```

0 comments on commit a723dc4

Please sign in to comment.