diff --git a/lib/fs.js b/lib/fs.js index 99defef..b897ba4 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -240,13 +240,13 @@ function copyDir(src, dest, options = {}, callback) { options = {}; } - return checkParent(dest).then() => _copyDir(src, dest, options, '').asCallback(callback); + return checkParent(dest).then(() => _copyDir(src, dest, options, '')).asCallback(callback); } -function _listDir(path, options = {}, parent = '') { +function _listDir(path, options, parent) { return _readAndFilterDir(path, options).map(item => { const currentPath = join(parent, item.path); - + if (item.isDirectory) { return _listDir(item.fullPath, options, currentPath); } @@ -269,11 +269,11 @@ function listDir(path, options = {}, callback) { function _listDirSync(path, options, parent) { return _readAndFilterDirSync(path, options).map(item => { const currentPath = join(parent, item.path); - + if (item.isDirectory) { return _listDirSync(item.fullPath, options, currentPath); } - + return currentPath; }).reduce(reduceFiles, []); } @@ -296,7 +296,7 @@ function escapeFileContent(content) { return escapeBOM(escapeEOL(content)); } -function readFile(path, options = {}, callback) { +function readFile(path, options = {}, callback) { if (!path) throw new TypeError('path is required!'); if (!callback && typeof options === 'function') { @@ -304,7 +304,6 @@ function readFile(path, options = {}, callback) { options = {}; } - options = options || {}; if (!options.hasOwnProperty('encoding')) options.encoding = 'utf8'; return readFileAsync(path, options).then(content => {