Skip to content

Commit e0a40ab

Browse files
author
Matt Wade
committed
Allows for raw diff output to stdout
Actually, this was a documented feature, but never implemented.
1 parent 02371f6 commit e0a40ab

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,16 @@ class DiffDevProdCommand extends Command {
494494
await fs.remove(CACHE_DIRECTORY);
495495
}
496496

497-
const raw_html_diff = Diff2html.html(diff_output);
498-
const html_diff = createHtmlDiff({ title: root_domain, diff: raw_html_diff });
499-
500-
await fs.writeFile(output_filename, html_diff);
501497
loud && this.log(chalk.green('Done computing all differences!'));
502-
loud && this.log(chalk.green(`Written to ${chalk.blue(output_filename)}`));
498+
if (output_filename === 'stdout') {
499+
this.log(diff_output);
500+
} else {
501+
const raw_html_diff = Diff2html.html(diff_output);
502+
const html_diff = createHtmlDiff({ title: root_domain, diff: raw_html_diff });
503+
504+
await fs.writeFile(output_filename, html_diff);
505+
loud && this.log(chalk.green(`Written to ${chalk.blue(output_filename)}`));
506+
}
503507
this.exit(0);
504508
}
505509
}
@@ -616,6 +620,7 @@ DiffDevProdCommand.examples = [
616620
`$ ddp --clean-config='{ "elements": [{ "remove": true, "selector": "script", "containsRegex": "jQuery v\\\\d+", "containsRegexFlags": "i" }] }' https://example.com`,
617621
`$ ddp --clean-config="clean-config.json" https://example.com`,
618622
`$ cat clean-config.json | ddp --clean-config=stdin https://example.com`,
623+
`$ ddp --quiet --output=stdout https://example.com`,
619624
];
620625

621626
DiffDevProdCommand.args = [

0 commit comments

Comments
 (0)