File tree 4 files changed +36
-8
lines changed
4 files changed +36
-8
lines changed Original file line number Diff line number Diff line change 82
82
"concat-stream" : " ^1.4.7" ,
83
83
"core-js" : " ^0.4.3" ,
84
84
"docopt" : " ^0.4.1" ,
85
+ "event-stream" : " ^3.2.1" ,
85
86
"glob" : " ^4.3.1" ,
86
87
"glob2base" : " 0.0.12" ,
87
88
"js-yaml" : " ^3.2.1" ,
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ Options:
20
20
` ;
21
21
22
22
const docopt = require ( 'docopt' ) . docopt ;
23
+ const es = require ( 'event-stream' ) ;
24
+ const vfs = require ( 'vinyl-fs' ) ;
23
25
const source = require ( 'vinyl-source-stream' ) ;
24
26
const pkg = require ( '../package.json' ) ;
25
27
const Environment = require ( './environment' ) ;
@@ -70,13 +72,31 @@ export default function cli(argv = process.argv.slice(2)) {
70
72
}
71
73
72
74
if ( ! options [ '<src>' ] . length ) {
73
- return process . stdin
74
- . pipe ( source ( ) )
75
- . pipe ( handler ( env ) )
76
- . on ( 'data' , cb ) ;
75
+ options [ '<src>' ] . push ( '.' )
77
76
}
78
77
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 ( )
80
100
}
81
101
82
102
/**
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const vfs = require('vinyl-fs');
10
10
*/
11
11
export default function recurse ( ) {
12
12
return through . obj ( function ( file , enc , cb ) {
13
- if ( file . isBuffer ( ) ) {
13
+ if ( file . isBuffer ( ) || file . isStream ( ) ) {
14
14
// Pass-through.
15
15
return cb ( null , file ) ;
16
16
}
Original file line number Diff line number Diff line change @@ -148,13 +148,20 @@ export default function sassdoc(...args) {
148
148
onEmpty ( data , env ) ;
149
149
} ) ;
150
150
151
+ let transform = pipe (
152
+ recurse ( ) ,
153
+ exclude ( env . exclude || [ ] ) ,
154
+ converter ( { from : 'sass' , to : 'scss' } ) ,
155
+ filter
156
+ ) ;
157
+
151
158
/* jshint ignore:start */
152
159
153
160
/**
154
161
* Returned Promise await the full sequence,
155
162
* instead of just the parsing step.
156
163
*/
157
- filter . promise = new Promise ( ( resolve , reject ) => {
164
+ transform . promise = new Promise ( ( resolve , reject ) => {
158
165
159
166
async function documentize ( ) {
160
167
try {
@@ -179,7 +186,7 @@ export default function sassdoc(...args) {
179
186
180
187
/* jshint ignore:end */
181
188
182
- return filter ;
189
+ return transform ;
183
190
}
184
191
}
185
192
You can’t perform that action at this time.
0 commit comments