Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -r option (write to stdout) #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ program
.usage('[options] [dir|file ...]')
.option('-O, --obj <str|path>', 'JSON/JavaScript options object or file')
.option('-o, --out <dir>', 'output the rendered HTML or compiled JavaScript to <dir>')
.option('-r, --print', 'print the rendered HTML to stdout')
.option('-p, --path <path>', 'filename used to resolve includes')
.option('-b, --basedir <path>', 'path used as root directory to resolve absolute includes')
.option('-P, --pretty', 'compile pretty HTML output')
Expand Down Expand Up @@ -286,8 +287,9 @@ function renderFile(path, rootPath) {
var dir = resolve(dirname(path));
mkdirp.sync(dir);
var output = options.client ? fn : fn(options);
fs.writeFileSync(path, output);
consoleLog(' ' + chalk.gray('rendered') + ' ' + chalk.cyan('%s'), normalize(path));
if (!program.print) { fs.writeFileSync(path, output); }
else { process.stdout.write(output); }
if (!program.print) { consoleLog(' ' + chalk.gray('rendered') + ' ' + chalk.cyan('%s'), normalize(path)); }
// Found directory
} else if (stat.isDirectory()) {
var files = fs.readdirSync(path);
Expand Down