Skip to content
Myr

Add tip on how to execute the current package's binary (#339)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent 8977752 · Browse files · 1 file+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−0 removed

  • other:+11 added−0 removed

1 file+11 added−0 removed

modified:readme.md+11 added
497 unmodified lines
498const subprocess = execa('cat')499fs.createReadStream('stdin.txt').pipe(subprocess.stdin)500```501502### Execute the current package's binary503504```js505const {getBinPathSync} = require('get-bin-path');506507const binPath = getBinPathSync();508const subprocess = execa(binPath);509```510511This 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.512513514## Related515516- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for `execa`517
18 unmodified lines