Skip to content

Use - for stdin #350

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

Merged
merged 1 commit into from
Jan 30, 2015
Merged
Show file tree
Hide file tree
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
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