From 6bcf4707b6f409dcf03a7cb948a6bbc41b792791 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 1 Jul 2019 10:00:00 +0200 Subject: [PATCH 1/3] Add tip on how to execute the current package's binary --- readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readme.md b/readme.md index fd5da3595f..57ca3bac22 100644 --- a/readme.md +++ b/readme.md @@ -499,6 +499,16 @@ 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 setup. ## Related From 35104af15cb810edefc6dbecf3ef76e00702dfb7 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Mon, 1 Jul 2019 10:00:00 +0200 Subject: [PATCH 2/3] Fix style --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 57ca3bac22..ffd7d6ff25 100644 --- a/readme.md +++ b/readme.md @@ -502,10 +502,10 @@ fs.createReadStream('stdin.txt').pipe(subprocess.stdin) ### Execute the current package's binary ```js -const { getBinPathSync } = require('get-bin-path') +const {getBinPathSync} = require('get-bin-path'); -const binPath = getBinPathSync() -const subprocess = execa(binPath) +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 setup. From d2aa790a52557f148e232d0ae898f321380f2c9a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 1 Jul 2019 22:39:00 +0700 Subject: [PATCH 3/3] Update readme.md --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ffd7d6ff25..97c037727c 100644 --- a/readme.md +++ b/readme.md @@ -508,7 +508,8 @@ 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 setup. +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