diff --git a/index.js b/index.js index 2039b80..9ba453c 100644 --- a/index.js +++ b/index.js @@ -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' @@ -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 } } diff --git a/package-lock.json b/package-lock.json index a7fbf25..3d8c237 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,16 @@ { "name": "aemsync", - "version": "5.0.3", + "version": "5.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aemsync", - "version": "5.0.3", + "version": "5.0.4", "license": "MIT", "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" @@ -1621,7 +1620,8 @@ "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "dev": true }, "node_modules/ms": { "version": "2.1.2", @@ -3636,7 +3636,8 @@ "minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "dev": true }, "ms": { "version": "2.1.2", diff --git a/package.json b/package.json index ee97651..b6bbe48 100644 --- a/package.json +++ b/package.json @@ -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"