Skip to content

Commit

Permalink
Use - for stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriangalliat committed Jan 30, 2015
1 parent 133057d commit 6c605dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ lint: .jshintrc
test: test/data/expected.stream.json dist
$(MOCHA) test/**/*.test.js
$(SASSDOC) --parse test/data/test.scss | diff - test/data/expected.json
$(SASSDOC) --parse < test/data/test.scss | diff - test/data/expected.stream.json
$(SASSDOC) --parse - < test/data/test.scss | diff - test/data/expected.stream.json
rm -rf sassdoc && $(SASSDOC) test/data/test.scss && [ -d sassdoc ]
rm -rf sassdoc && $(SASSDOC) < test/data/test.scss && [ -d sassdoc ]
rm -rf sassdoc && $(SASSDOC) - < test/data/test.scss && [ -d sassdoc ]

test/data/expected.stream.json: test/data/expected.json
test/data/stream $< > $@
Expand Down
9 changes: 8 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let doc = `
Usage:
sassdoc - [options]
sassdoc <src>... [options]
sassdoc [options]
Expand Down Expand Up @@ -29,6 +30,12 @@ const errors = require('./errors');

export default function cli(argv = process.argv.slice(2)) {
let options = docopt(doc, { version: pkg.version, argv: argv });

if (!options['-'] && !options['<src>'].length) {
// Trigger help display.
docopt(doc, { version: pkg.version, argv: ['--help'] });
}

let logger = new Logger(options['--verbose'], options['--debug'] || process.env.SASSDOC_DEBUG);
let env = new Environment(logger, options['--strict']);

Expand Down Expand Up @@ -69,7 +76,7 @@ export default function cli(argv = process.argv.slice(2)) {
cb = data => console.log(JSON.stringify(data, null, 2));
}

if (!options['<src>'].length) {
if (options['-']) {
return process.stdin
.pipe(source())
.pipe(handler(env))
Expand Down

0 comments on commit 6c605dd

Please sign in to comment.