Skip to content

Commit

Permalink
Update fs.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahDragon committed Dec 20, 2018
1 parent 49fc1d9 commit e2b2c92
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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, []);
}
Expand All @@ -296,15 +296,14 @@ 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') {
callback = options;
options = {};
}

options = options || {};
if (!options.hasOwnProperty('encoding')) options.encoding = 'utf8';

return readFileAsync(path, options).then(content => {
Expand Down

0 comments on commit e2b2c92

Please sign in to comment.