🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mk_path666

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mk_path666 - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+16
-17
lib/mk_path.js

@@ -6,2 +6,4 @@ const fs = require('fs')

const chalk = require("chalk");
const p_mkdir = promisify(fs.mkdir);

@@ -25,7 +27,7 @@ const p_exists = promisify(fs.exists)

let pathArr = dirpath.split("/");
console.log(pathArr)
//console.log(pathArr);
/*判断是否是绝对路径*/
let recentDir = pathArr[0] ? process.env.PWD : "/";
//console.log(chalk.blue(recentDir));
/*依次尝试创建目录*/

@@ -35,18 +37,17 @@ (async function(){

recentDir = path.join(recentDir,pathArr[i]);
console.log(i + " " + recentDir);
//console.log(i + " " + recentDir);
try{
console.log("writting " + recentDir);
//console.log("writting " + recentDir);
await p_mkdir(recentDir);
console.log(recentDir + " sucess");
}catch(e){ console.log(recentDir + " err");}
//console.log(recentDir + " sucess");
}catch(e){
if(/file already exists/.test(e.message)){
//if it is empty it may throw unhanddle error
}else{
mk_path.emit("err",e,dirpath);
return null;
}
}
}
/*刚才是真的傻逼,这个函数应该写在async函数里面*/
/*fs.exists(dirpath,(exists)=>{
if(exists) {
mk_path.emit("sucess",null,dirpath)
}else{
mk_path.emit("sucess",new Error("fail to mk path"),dirpath)
}
});*/
let exists = await p_exists(dirpath)

@@ -56,3 +57,3 @@ if(exists) {

}else{
mk_path.emit("sucess",new Error("fail to mk path"),dirpath)
mk_path.emit("err",new Error("fail to mk path"),dirpath)
}

@@ -65,3 +66,1 @@

mk_path.dir("../hel/lo/wor/ld",(err)=>{if(err) throw err});

@@ -6,3 +6,3 @@ {

},
"version": "0.0.1",
"version": "0.0.2",
"description": "mkpath directly",

@@ -19,3 +19,4 @@ "repository": {

"dependencies": {
"chalk": "^2.4.1"
}
}

@@ -10,3 +10,3 @@ ## 目标

```
$ npm install mk_path
$ npm install mk_path666

@@ -13,0 +13,0 @@ ```