@@ -122,10 +122,23 @@ module.exports = Command.extend({
122
122
const index = inPath . lastIndexOf ( '/' )
123
123
parallelLimit ( res . map ( ( element ) => ( callback ) => {
124
124
if ( ! fs . statSync ( element ) . isDirectory ( ) ) {
125
+ element . substring ( index + 1 , element . length )
125
126
i . write ( {
126
127
path : element . substring ( index + 1 , element . length ) ,
127
128
stream : fs . createReadStream ( element )
128
129
} )
130
+ } else {
131
+ fs . readdir ( element , ( err , files ) => {
132
+ if ( err ) {
133
+ throw err
134
+ }
135
+ if ( files . length === 0 ) {
136
+ i . write ( {
137
+ path : element . substring ( index + 1 , element . length ) ,
138
+ stream : null
139
+ } )
140
+ }
141
+ } )
129
142
}
130
143
callback ( )
131
144
} ) , 10 , ( err ) => {
@@ -135,11 +148,25 @@ module.exports = Command.extend({
135
148
i . end ( )
136
149
} )
137
150
} else {
138
- rs = fs . createReadStream ( inPath )
139
- inPath = inPath . substring ( inPath . lastIndexOf ( '/' ) + 1 , inPath . length )
140
- filePair = { path : inPath , stream : rs }
141
- i . write ( filePair )
142
- i . end ( )
151
+ if ( ! fs . statSync ( inPath ) . isDirectory ( ) ) {
152
+ rs = fs . createReadStream ( inPath )
153
+ inPath = inPath . substring ( inPath . lastIndexOf ( '/' ) + 1 , inPath . length )
154
+ filePair = { path : inPath , stream : rs }
155
+ i . write ( filePair )
156
+ i . end ( )
157
+ } else {
158
+ fs . readdir ( inPath , ( err , files ) => {
159
+ if ( err ) {
160
+ throw err
161
+ }
162
+ if ( files . length === 0 ) {
163
+ i . write ( {
164
+ path : inPath ,
165
+ stream : null
166
+ } )
167
+ }
168
+ } )
169
+ }
143
170
}
144
171
} )
145
172
}
0 commit comments