Skip to content

Commit

Permalink
optimize mkdir method
Browse files Browse the repository at this point in the history
  • Loading branch information
lichengyin committed Aug 21, 2018
1 parent d45c18a commit 6879f9d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Expand Up @@ -429,8 +429,7 @@ exports.isDirectory = isDirectory;
* @param {String} mode [path mode]
* @return {Boolean} []
*/
function chmod(p, mode = '0777') {
if (!isExist(p)) return false;
function chmod(p, mode) {
try {
fs.chmodSync(p, mode);
return true;
Expand All @@ -443,8 +442,11 @@ exports.chmod = chmod;
/**
* make dir
*/
function mkdir(dir, mode = '0777') {
if (isExist(dir)) return chmod(dir, mode);
function mkdir(dir, mode) {
if (isExist(dir)) {
if (mode) return chmod(dir, mode);
return true;
}
const pp = path.dirname(dir);
if (isExist(pp)) {
try {
Expand Down

0 comments on commit 6879f9d

Please sign in to comment.