juice icon indicating copy to clipboard operation
juice copied to clipboard

Allow juice to run with stdin and stdout if no filenames passed

Open kewisch opened this issue 9 years ago • 4 comments

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.

kewisch avatar Oct 24 '16 20:10 kewisch

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

robin-a-meade avatar Feb 01 '19 06:02 robin-a-meade

I'd very much like to see this feature implemented.

tremby avatar Apr 07 '19 01:04 tremby

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

adueck avatar Apr 25 '19 20:04 adueck

I'd like to see this implemented too

reyronald avatar Jun 08 '21 13:06 reyronald