Skip to content

Commit

Permalink
Removed minimist dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavoja committed Sep 20, 2022
1 parent 6bbc4df commit 6f9dfe6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
43 changes: 15 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node
import fs from 'fs'
import minimist from 'minimist'
import fetch, { FormData, File } from 'node-fetch'
import path from 'path'
import watch from 'simple-watcher'
Expand Down Expand Up @@ -233,35 +232,23 @@ function debugResult (result) {
}

function getArgs () {
const args = minimist(process.argv.slice(2), {
default: {
w: DEFAULTS.workingDir,
t: DEFAULTS.targets,
e: DEFAULTS.exclude,
d: DEFAULTS.delay,
c: DEFAULTS.checkIfUp,
q: DEFAULTS.packmgrPath,
v: DEFAULTS.verbose
}
})

let payload = null
if (args.p) {
payload = (Array.isArray(args.p) ? args.p : [args.p]).map((p) =>
path.resolve(p)
)
}
const args = [' ', ...process.argv.slice(2)].join(' ').split(' -').slice(1).reduce((obj, arg) => {
const [key, value] = arg.split(/ (.*)/s)
obj[key] = obj[key] ?? []
obj[key].push(value)
return obj
}, {})

return {
payload,
workingDir: path.resolve(args.w),
targets: Array.isArray(args.t) ? args.t : [args.t],
exclude: Array.isArray(args.e) ? args.e : [args.e],
delay: args.d,
checkIfUp: args.c,
packmgrPath: args.q,
help: args.h,
verbose: args.v
payload: args.p ? args.p.map(p => path.resolve(p)) : null,
workingDir: path.resolve(args?.d?.[0] ?? DEFAULTS.workingDir),
targets: args.t ?? DEFAULTS.targets,
exclude: args.e ?? DEFAULTS.exclude,
delay: Number(args?.d?.[0]) || DEFAULTS.delay,
checkIfUp: !!args.c,
packmgrPath: args?.q?.pop?.() ?? DEFAULTS.packmgrPath,
help: !!args.h,
verbose: !!args.v
}
}

Expand Down
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"dependencies": {
"adm-zip": "0.5.9",
"globrex": "0.1.2",
"minimist": "1.2.6",
"node-fetch": "3.2.10",
"simple-watcher": "5.0.1",
"xml-to-json-stream": "1.1.0"
Expand Down

0 comments on commit 6f9dfe6

Please sign in to comment.