Allow juice to run with stdin and stdout if no filenames passed
I'd like to be able to use juice to pipe from stdin and send to stdout, for example when using a filter in vim. I know I can do juice /dev/stdin /dev/stdout, but it would be more elegant to just execute juice without arguments, or at least support - for stdin/stdout.
A workaround: a wrapper script:
juicew
#!/usr/bin/bash
file=$(mktemp) || { echo "Couldn't create temp file" >&2; exit 1; }
trap "rm $file" EXIT
juice "$@" /dev/stdin "$file"
cat "$file"
Test:
$ echo "<style>div{color:red;}</style><div/>" | juicew
<div style="color: red;">
</div>
Update 2020-07-26: Using node 10.x, I get an error when I try to use /dev/stdout:
$ echo "<style>div{color:red;}</style><div/>" | juice /dev/stdin /dev/stdout
Error: ESPIPE: invalid seek, write
That's why my wrapper script above used a temp file. With node 12.x, I no longer get that error. I can therefore simplify my workaround wrapper script to:
#!/usr/bin/bash
juice "$@" /dev/stdin /dev/stdout
I'd very much like to see this feature implemented.
I made a little cli wrapper that does something this with inline-css, before I just found out that juice existed.
I wanted to do css inlining from a different language environment, and stdin / stdout seemed like the simplest solution.
Perhaps something like this could be worked in with juice? Repo: inline-css-cli
I'd like to see this implemented too