Merge pull request #558 from embark-framework/bug_fix/console-dir-test

Fix testing a directory without ending slash
This commit is contained in:
Iuri Matias 2018-06-19 11:40:44 -04:00 committed by GitHub
commit 9574562602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {