Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lyftp

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lyftp - npm Package Compare versions

Comparing version 1.0.10 to 1.1.0

49

core.js

@@ -43,2 +43,3 @@ let path = require('path')

Core.prototype = {
// check localDir isDirectory or isFile , localDir需要需要是一个绝对路径
put(localDir, remoteDir){

@@ -55,12 +56,6 @@ const stat = fs.statSync(localDir)

},
// 上传文件夹
// upload dir
putDir(localDir, remoteDir){
// 对文件夹进行遍历
// return new Promise(res => {
// this.ftp.mkdir('webApp/women/xxx', true, err=>{
// console.log(err)
// })
// })
let list = getDirList(localDir)

@@ -82,3 +77,3 @@

},
// 上传文件
// upload file
putFile(localP, remoteP){

@@ -93,8 +88,3 @@ console.log(`路径 ${localP} ---> ${remoteP}`);

this.ftp.put(localP, remoteP, (err)=>{
console.log('文件上传完成')
if(err){
console.log(err);
return
}
console.log('上传成功:', localP , '--->', remoteP);
err ? console.log('上传失败:', localP , '--->', remoteP, err) : console.log('上传成功:', localP , '--->', remoteP);
resolve()

@@ -105,2 +95,3 @@ })

},
// make dir
mkdir(remoteP){

@@ -113,3 +104,2 @@ let p = remoteP.split('/').map(item => item.trim()).filter(item => item)

let LIST = pathArr

@@ -121,2 +111,3 @@

// 如果路径不存在,第二参数为true时,他会自动帮你创建
this.ftp.mkdir(remoteP, true, err=>{

@@ -126,35 +117,11 @@ let success = !err || err.message.toLowerCase().match('file exists')

console.log(`路径创建成功 ==> ${P}`)
res()
} else {
console.log('路径创建失败', err)
res()
//
// console.log(`路径创建失败,从根目录开始创建 -->`, LIST)
//
// this.mkdirList(LIST, 0, res)
}
res()
})
})
},
mkdirList(LIST, index, res){
if(index == LIST.length) {
console.log('LIST upload end!!!!!!!!!!')
res()
} else {
let P = LIST[index]
let ff = this.ftp.mkdir(P, true, err=>{
console.log('??????????????????')
let success = !err || err.message.toLowerCase().match('file exists')
if(success){
console.log('创建文件夹', P);
this.mkdirList(LIST, ++index, res)
}else{
console.log('创建失败', P, err.message);
}
})
}
},
}
}
module.exports = Core

17

index.js

@@ -54,2 +54,3 @@ #!/usr/bin/env node

Promise.all(list.map(localPath => {
// localPath转绝对路径
localPath = path.resolve(configPath, localPath)

@@ -86,15 +87,9 @@ return lftp.put(localPath, remotePath)

return
} else if(KEY == '--arr') {
} else if(KEY == '--files') {
return upload(args.slice(1), config)
}
// 上传默认路径的文件
if (KEY == 'upload') {
console.log('上传默认路径内的文件');
let list = config.upload.default
upload(list, config)
} else {
let list = config.upload[KEY]
upload(list, config)
}
// 获取key,上传对应文件
let list = config.upload[KEY] || []
// list长度不为空,就上传,反则报错
list.length ? upload(list, config) : console.log(`ERROR: ${KEY}不存在.ftprc -> upload 中 \n ${JSON.stringify(config, null, 4)}`)
{
"name": "lyftp",
"version": "1.0.10",
"version": "1.1.0",
"description": "lyftp is ftp package, you can upload an entire folder or a file",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,3 +16,3 @@ # lyftp

"default": ["not/"],
"chat": ["wptFtp/not/test/a.txt", "wptFtp/not/test2/灯火阑珊.js"],
"chat": ["wptFtp/not/test/a.txt", "wptFtp/not/test2/"],
"lys": ["lys/bin"]

@@ -34,3 +34,13 @@ }

## 规则
- 如果上传路径为空,则上传.ftprc下的所有文件
## 上传
被上传的文件/文件夹路径,需要是相对.ftprc的相对路径或者是一个绝对路径
### 命令行上传
```bash
lyftp chat
```
### 命令行指定文件/文件夹
```bash
lyftp --files wptFtp/not/test/a.txt wptFtp/not/test2/
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc