From 82d2a4adff4e205864dd49bd0a5c352fc54ecdee Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 1 Jul 2019 08:39:15 -0700 Subject: [PATCH] Add tip on how to execute the current package's binary (#339) --- readme.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/readme.md b/readme.md index fd5da3595..97c037727 100644 --- a/readme.md +++ b/readme.md @@ -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