Feature: add commandline argvs support for picgo app

for example: picgo.exe ./xxx.jpg
This commit is contained in:
PiEgg
2019-04-14 15:41:48 +08:00
parent c64959a139
commit 6db86ec359
2 changed files with 90 additions and 30 deletions

View File

@@ -0,0 +1,29 @@
import path from 'path'
import fs from 'fs-extra'
const getUploadFiles = (argv = process.argv, cwd = process.cwd()) => {
let files = argv.slice(1)
let result = []
if (files.length > 0) {
result = files.map(item => {
if (path.isAbsolute(item)) {
return {
path: item
}
} else {
let tempPath = path.join(cwd, item)
if (fs.existsSync(tempPath)) {
return {
path: tempPath
}
} else {
return null
}
}
}).filter(item => item !== null)
}
return result
}
export {
getUploadFiles
}