mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-20 01:18:52 +00:00
Merge pull request #558 from embark-framework/bug_fix/console-dir-test
Fix testing a directory without ending slash
This commit is contained in:
commit
9574562602
@ -32,14 +32,23 @@ module.exports = {
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function getFiles(next) {
|
||||
if (filePath.substr(-1) !== '/') {
|
||||
return fs.access(filePath, (err) => {
|
||||
function checkIfDir(next) {
|
||||
if (filePath.substr(-1) === '/') {
|
||||
return next(null, null);
|
||||
}
|
||||
fs.stat(filePath, (err, stats) => {
|
||||
if (err) {
|
||||
return next(`File "${filePath}" doesn't exist or you don't have permission to it`.red);
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
return next(null, null);
|
||||
}
|
||||
next(null, [filePath]);
|
||||
});
|
||||
},
|
||||
function getFiles(files, next) {
|
||||
if (files) {
|
||||
return next(null, files);
|
||||
}
|
||||
getFilesFromDir(filePath, (err, files) => {
|
||||
if (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user