Comparing version 1.0.4 to 1.0.5
46
core.js
@@ -101,19 +101,37 @@ let path = require('path') | ||
p.forEach(item => pathArr.push(pathStr += item+ '/')) | ||
// 直接创建文件夹, | ||
return Promise.all( | ||
pathArr.map(item=>{ | ||
return new Promise((resolve, reject) => { | ||
this.ftp.mkdir(item, err=>{ | ||
let success = !err || err.message.toLowerCase().match('file exists') | ||
if(success){ | ||
console.log('创建文件夹', item); | ||
resolve() | ||
}else{ | ||
console.log(item, err.message); | ||
reject(err) | ||
} | ||
return new Promise((res, rej) => { | ||
let P = p.join('/') | ||
this.ftp.mkdir(P, err=>{ | ||
let success = !err || err.message.toLowerCase().match('file exists') | ||
if(success) { | ||
console.log(`路径创建成功 ==> ${P}`) | ||
res() | ||
} else { | ||
Promise.all( | ||
pathArr.map(item=>{ | ||
return new Promise((resolve, reject) => { | ||
this.ftp.mkdir(item, err=>{ | ||
let success = !err || err.message.toLowerCase().match('file exists') | ||
if(success){ | ||
console.log('创建文件夹', item); | ||
resolve() | ||
}else{ | ||
console.log(item, err.message); | ||
reject(err) | ||
} | ||
}) | ||
}) | ||
}) | ||
).then(success => { | ||
res() | ||
}, fail => { | ||
rej() | ||
}) | ||
}) | ||
} | ||
}) | ||
) | ||
}) | ||
} | ||
@@ -120,0 +138,0 @@ } |
{ | ||
"name": "lyftp", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "lyftp is ftp package, you can upload an entire folder or a file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
7927
196