Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix adding empty dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
nginnever committed May 25, 2016
1 parent 8fb1c49 commit 928bf17
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,23 @@ module.exports = Command.extend({
const index = inPath.lastIndexOf('/')
parallelLimit(res.map((element) => (callback) => {
if (!fs.statSync(element).isDirectory()) {
element.substring(index + 1, element.length)
i.write({
path: element.substring(index + 1, element.length),
stream: fs.createReadStream(element)
})
} else {
fs.readdir(element, (err, files) => {
if (err) {
throw err
}
if (files.length === 0) {
i.write({
path: element.substring(index + 1, element.length),
stream: null
})
}
})
}
callback()
}), 10, (err) => {
Expand All @@ -135,11 +148,25 @@ module.exports = Command.extend({
i.end()
})
} else {
rs = fs.createReadStream(inPath)
inPath = inPath.substring(inPath.lastIndexOf('/') + 1, inPath.length)
filePair = {path: inPath, stream: rs}
i.write(filePair)
i.end()
if (!fs.statSync(inPath).isDirectory()) {
rs = fs.createReadStream(inPath)
inPath = inPath.substring(inPath.lastIndexOf('/') + 1, inPath.length)
filePair = {path: inPath, stream: rs}
i.write(filePair)
i.end()
} else {
fs.readdir(inPath, (err, files) => {
if (err) {
throw err
}
if (files.length === 0) {
i.write({
path: inPath,
stream: null
})
}
})
}
}
})
}
Expand Down

0 comments on commit 928bf17

Please sign in to comment.