cac
Advanced tools
Comparing version 6.2.1 to 6.2.2
@@ -7,3 +7,3 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const minimist_1 = __importDefault(require("minimist")); | ||
const mri_1 = __importDefault(require("mri")); | ||
const Command_1 = __importDefault(require("./Command")); | ||
@@ -75,4 +75,4 @@ const utils_1 = require("./utils"); | ||
for (const command of this.commands) { | ||
const minimistOptions = utils_1.getMinimistOptions(this.globalCommand, command); | ||
const { args, options, originalOptions } = this.minimist(argv.slice(2), minimistOptions); | ||
const mriOptions = utils_1.getMriOptions(this.globalCommand, command); | ||
const { args, options, originalOptions } = this.mri(argv.slice(2), mriOptions); | ||
const commandName = args[0]; | ||
@@ -95,4 +95,4 @@ if (command.isMatched(commandName)) { | ||
if (command.name === '') { | ||
const minimistOptions = utils_1.getMinimistOptions(this.globalCommand, command); | ||
const { args, options, originalOptions } = this.minimist(argv.slice(2), minimistOptions); | ||
const mriOptions = utils_1.getMriOptions(this.globalCommand, command); | ||
const { args, options, originalOptions } = this.mri(argv.slice(2), mriOptions); | ||
this.matchedCommand = command; | ||
@@ -110,4 +110,4 @@ this.args = args; | ||
} | ||
const globalMinimistOptions = utils_1.getMinimistOptions(this.globalCommand); | ||
const { args, options } = this.minimist(argv.slice(2), globalMinimistOptions); | ||
const globalMriOptions = utils_1.getMriOptions(this.globalCommand); | ||
const { args, options } = this.mri(argv.slice(2), globalMriOptions); | ||
this.args = args; | ||
@@ -126,9 +126,15 @@ this.options = options; | ||
} | ||
minimist(argv, minimistOptions) { | ||
const parsed = minimist_1.default(argv, Object.assign({ | ||
'--': true | ||
}, minimistOptions)); | ||
mri(argv, mriOptions) { | ||
let argsAfterDoubleDashes = []; | ||
const doubleDashesIndex = argv.indexOf('--'); | ||
if (doubleDashesIndex > -1) { | ||
argsAfterDoubleDashes = argv.slice(0, doubleDashesIndex); | ||
argv = argv.slice(doubleDashesIndex + 1); | ||
} | ||
const parsed = mri_1.default(argv, mriOptions); | ||
const args = parsed._; | ||
delete parsed._; | ||
const options = {}; | ||
const options = { | ||
'--': argsAfterDoubleDashes | ||
}; | ||
for (const key of Object.keys(parsed)) { | ||
@@ -135,0 +141,0 @@ options[utils_1.camelcase(key)] = parsed[key]; |
@@ -31,3 +31,3 @@ "use strict"; | ||
}; | ||
exports.getMinimistOptions = (globalCommand, subCommand) => { | ||
exports.getMriOptions = (globalCommand, subCommand) => { | ||
const options = [ | ||
@@ -46,3 +46,3 @@ ...globalCommand.options, | ||
// Only need to set the default value of the first name | ||
// Since minimist will automatically do the rest for alias names | ||
// Since mri will automatically do the rest for alias names | ||
res[option.names[0]] = option.config.default; | ||
@@ -49,0 +49,0 @@ } |
{ | ||
"name": "cac", | ||
"version": "6.2.1", | ||
"version": "6.2.2", | ||
"description": "Simple yet powerful framework for building command-line apps.", | ||
@@ -27,3 +27,3 @@ "repository": { | ||
"@types/jest": "^23.3.9", | ||
"@types/minimist": "^1.2.0", | ||
"@types/mri": "^1.1.0", | ||
"cz-conventional-changelog": "^2.1.0", | ||
@@ -43,3 +43,3 @@ "eslint-config-rem": "^3.0.0", | ||
"dependencies": { | ||
"minimist": "^1.2.0" | ||
"mri": "^1.1.1" | ||
}, | ||
@@ -46,0 +46,0 @@ "release": { |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
interface ParsedArgv { | ||
args: string[]; | ||
args: ReadonlyArray<string>; | ||
options: { | ||
@@ -24,3 +24,3 @@ [k: string]: any; | ||
*/ | ||
args: string[]; | ||
args: ReadonlyArray<string>; | ||
/** | ||
@@ -46,3 +46,3 @@ * Parsed CLI options, camelCased | ||
parse(argv?: string[]): ParsedArgv; | ||
private minimist; | ||
private mri; | ||
private runCommandAction; | ||
@@ -49,0 +49,0 @@ } |
@@ -8,3 +8,3 @@ import Command from './Command'; | ||
}[]; | ||
export declare const getMinimistOptions: (globalCommand: Command, subCommand?: Command | undefined) => { | ||
export declare const getMriOptions: (globalCommand: Command, subCommand?: Command | undefined) => { | ||
default: {}; | ||
@@ -11,0 +11,0 @@ boolean: string[]; |
35021
628
+ Addedmri@^1.1.1
+ Addedmri@1.2.0(transitive)
- Removedminimist@^1.2.0
- Removedminimist@1.2.8(transitive)