zurb / inky-cli

Command-line interface for the Inky templating language.
MIT License
13 stars 2 forks source link

Support stdin, stdout #4

Open btubbs opened 8 years ago

btubbs commented 8 years ago

It would be a lot easier to use inky-cli in my Makefile if it could accept input on stdin, and print output to stdout. As it is, I'm going to have to create temporary files in between inky processing and CSS inlining.

(I know you have your own pipeline of Grunt tasks, but I don't want to use Grunt.)

A common CLI pattern is to use a dash ("-") as the filename argument to signal that input should be read from stdin instead of a file, or be printed to stdout instead of a file. Could inky-cli do that?

rclmenezes commented 7 years ago

For now, I made a handy dandy script:

const Inky = require('inky').Inky;
const cheerio = require('cheerio');
const getStdin = require('get-stdin');

const options = {};
const inky = new Inky(options);
getStdin().then(input => {
    const html = cheerio.load(input);
    const convertedHtml = inky.releaseTheKraken(html);
    console.log(convertedHtml);
});