File tree Expand file tree Collapse file tree 4 files changed +41
-12
lines changed Expand file tree Collapse file tree 4 files changed +41
-12
lines changed Original file line number Diff line number Diff line change 8282 "concat-stream" : " ^1.4.7" ,
8383 "core-js" : " ^0.4.3" ,
8484 "docopt" : " ^0.4.1" ,
85+ "event-stream" : " ^3.2.1" ,
8586 "glob" : " ^4.3.1" ,
8687 "glob2base" : " 0.0.12" ,
8788 "js-yaml" : " ^3.2.1" ,
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ Options:
2020` ;
2121
2222const docopt = require ( 'docopt' ) . docopt ;
23+ const es = require ( 'event-stream' ) ;
24+ const vfs = require ( 'vinyl-fs' ) ;
2325const source = require ( 'vinyl-source-stream' ) ;
2426const pkg = require ( '../package.json' ) ;
2527const Environment = require ( './environment' ) ;
@@ -70,13 +72,31 @@ export default function cli(argv = process.argv.slice(2)) {
7072 }
7173
7274 if ( ! options [ '<src>' ] . length ) {
73- return process . stdin
74- . pipe ( source ( ) )
75- . pipe ( handler ( env ) )
76- . on ( 'data' , cb ) ;
75+ options [ '<src>' ] . push ( '.' ) ;
7776 }
7877
79- handler ( options [ '<src>' ] , env ) . then ( cb ) ;
78+ let stdin = false ;
79+
80+ let sources = vfs . src ( options [ '<src>' ] . filter ( x => {
81+ if ( x === '-' ) {
82+ stdin = true ;
83+ return false ;
84+ }
85+
86+ return true ;
87+ } ) ) ;
88+
89+ if ( stdin ) {
90+ sources = es . merge (
91+ process . stdin . pipe ( source ( ) ) ,
92+ sources
93+ ) ;
94+ }
95+
96+ let stream = handler ( env ) ;
97+ stream . promise . then ( cb ) ;
98+
99+ sources . pipe ( stream ) . resume ( ) ;
80100}
81101
82102/**
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const vfs = require('vinyl-fs');
1010 */
1111export default function recurse ( ) {
1212 return through . obj ( function ( file , enc , cb ) {
13- if ( file . isBuffer ( ) ) {
13+ if ( file . isBuffer ( ) || file . isStream ( ) ) {
1414 // Pass-through.
1515 return cb ( null , file ) ;
1616 }
Original file line number Diff line number Diff line change @@ -34,10 +34,17 @@ export function parseFilter(env = {}) {
3434 let parser = new Parser ( env , env . theme && env . theme . annotations ) ;
3535 let filter = parser . stream ( ) ;
3636
37- filter . promise
37+ let transform = pipe (
38+ recurse ( ) ,
39+ exclude ( env . exclude || [ ] ) ,
40+ converter ( { from : 'sass' , to : 'scss' } ) ,
41+ filter
42+ ) ;
43+
44+ transform . promise = filter . promise
3845 . then ( data => sorter ( data ) ) ;
3946
40- return filter ;
47+ return transform ;
4148}
4249
4350/**
@@ -199,9 +206,7 @@ export function parse(...args) { // jshint ignore:line
199206 * @return {Promise }
200207 */
201208 async function documentize ( env ) {
202- let data = await baseDocumentize ( env ) ;
203-
204- return data ;
209+ return await baseDocumentize ( env ) ;
205210 }
206211
207212 /* jshint ignore:end */
@@ -220,7 +225,10 @@ export function parse(...args) { // jshint ignore:line
220225 } , cb ) ;
221226 } ) ;
222227
223- return pipe ( parse , filter ) ;
228+ let transform = pipe ( parse , filter ) ;
229+ transform . promise = parse . promise ;
230+
231+ return transform ;
224232 }
225233}
226234
You can’t perform that action at this time.
0 commit comments