Skip to content

Commit

Permalink
Add tip on how to execute the current package's binary (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored and sindresorhus committed Jul 1, 2019
1 parent 8977752 commit 82d2a4a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions readme.md
Expand Up @@ -499,6 +499,17 @@ const subprocess = execa('cat')
fs.createReadStream('stdin.txt').pipe(subprocess.stdin)
```

### Execute the current package's binary

```js
const {getBinPathSync} = require('get-bin-path');

const binPath = getBinPathSync();
const subprocess = execa(binPath);
```

This is useful when testing the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` `bin` field is correctly set up.


## Related

Expand Down

0 comments on commit 82d2a4a

Please sign in to comment.