Comparing version 1.0.7 to 1.0.8
@@ -82,3 +82,3 @@ let path = require('path') | ||
putFile(localP, remoteP){ | ||
console.log('路径', localP, remoteP); | ||
console.log(`路径 ${localP} ---> ${remoteP}`); | ||
// 文件名所在文件夹 | ||
@@ -91,2 +91,3 @@ let REMOTE_PATH = remoteP.slice(0, remoteP.lastIndexOf('/')) | ||
this.ftp.put(localP, remoteP, (err)=>{ | ||
console.log('文件上传完成') | ||
if(err){ | ||
@@ -93,0 +94,0 @@ console.log(err); |
64
index.js
@@ -42,2 +42,38 @@ #!/usr/bin/env node | ||
// 上传文件 | ||
function upload(list, config){ | ||
let ftp = new FTP() | ||
let lftp = new LFTP(ftp, configPath) | ||
// 远程文件夹 | ||
let {remotePath} = config | ||
remotePath = `/${remotePath}/` | ||
ftp.on('ready', () => { | ||
Promise.all(list.map(localPath => { | ||
localPath = path.resolve(configPath, localPath) | ||
return lftp.put(localPath, remotePath) | ||
})).then(msg => { | ||
console.log('上传完毕!') | ||
process.exit() | ||
}) | ||
}) | ||
// 连接时间 | ||
config.connTimeout = 1000 | ||
config.pasvTimeout = 1000 | ||
config.keepalive = 1000 | ||
ftp.on('err', err=>{ | ||
console.log('ftp上传出错', err) | ||
}) | ||
ftp.on('end', msg=>{ | ||
console.log('ftp连接中断', msg) | ||
}) | ||
ftp.connect(config) | ||
} | ||
const KEY = args[0] | ||
@@ -50,10 +86,6 @@ | ||
return | ||
} else if(KEY == '--arr') { | ||
return upload(args.slice(1), config) | ||
} | ||
let ftp = new FTP() | ||
let lftp = new LFTP(ftp, configPath) | ||
let {remotePath} = config | ||
remotePath = `/${remotePath}/` | ||
// 上传默认路径的文件 | ||
@@ -63,23 +95,7 @@ if (KEY == 'upload') { | ||
let list = config.upload.default | ||
upload(list) | ||
upload(list, config) | ||
} else { | ||
let list = config.upload[KEY] | ||
upload(list) | ||
upload(list, config) | ||
} | ||
function upload(list){ | ||
ftp.on('ready', () => { | ||
Promise.all(list.map(localPath => { | ||
localPath = path.resolve(configPath, localPath) | ||
return lftp.put(localPath, remotePath) | ||
})).then(msg => { | ||
console.log('上传完毕!') | ||
process.exit() | ||
}) | ||
}) | ||
} | ||
config.keepalive = 1000000000 | ||
ftp.connect(config) |
{ | ||
"name": "lyftp", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "lyftp is ftp package, you can upload an entire folder or a file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8340
213