I have an alias in my .bashrc for bunyan:
$ alias bsh
alias bsh='bunyan -o short'
This line runs fine in bash:
$ coffee src/index.coffee | bsh
But if I put the same thing in 'scripts'
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"coffee":"coffee src/index.coffee | bsh"
},
And npm run coffee
, it fails:
> coffee src/index.coffee | bsh
sh: bsh: command not found
events.js:141
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:870:11)
at WriteWrap.afterWrite (net.js:769:14)
So at random I tried putting in ||
instead of |
and it worked. I can't figure out why though. I don't have to escape pipe characters in JSON as far as I know.
However it doesn't actually pipe the output to the bsh alias.
The actual fix is to use "coffee":"coffee src/index.coffee | bunyan -o short"
-- get rid of the alias completely.
How can I use a bash alias in an npm script?