Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft of changing unsupported minimist to yargs-parser #322

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions dist/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _ = require('lodash');
var minimist = require('minimist');
const argParser = require('yargs-parser');
var strip = require('strip-ansi');

var util = {
Expand All @@ -32,7 +32,7 @@ var util = {
}
} while (match !== null);

arr = minimist(arr, opts);
arr = argParser(arr, opts);
arr._ = arr._ || [];
return arr;
},
Expand Down Expand Up @@ -216,8 +216,11 @@ var util = {
}

// Types are custom arg types passed
// into `minimist` as per its docs.
// into `argParser` as per its docs.
var types = cmd._types || {};
types.configuration = {
"camel-case-expansion": false
}

// Make a list of all boolean options
// registered for this command. These are
Expand Down Expand Up @@ -256,7 +259,7 @@ var util = {
return match;
});

// Use minimist to parse the args.
// Use argParser to parse the args.
var parsedArgs = this.parseArgs(passedArgs, types);

function validateArg(arg, cmdArg) {
Expand Down Expand Up @@ -461,4 +464,4 @@ var util = {
* Expose `util`.
*/

module.exports = exports = util;
module.exports = exports = util;
12 changes: 7 additions & 5 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const _ = require('lodash');
const minimist = require('minimist');
const argParser = require('yargs-parser');
const strip = require('strip-ansi');

const util = {
Expand All @@ -30,7 +30,7 @@ const util = {
}
} while (match !== null);

arr = minimist(arr, opts);
arr = argParser(arr, opts);
arr._ = arr._ || [];
return arr;
},
Expand Down Expand Up @@ -212,9 +212,11 @@ const util = {
}

// Types are custom arg types passed
// into `minimist` as per its docs.
// into `argParser` as per its docs.
const types = cmd._types || {};

types.configuration = {
"camel-case-expansion": false
}
// Make a list of all boolean options
// registered for this command. These are
// simply commands that don't have required
Expand Down Expand Up @@ -252,7 +254,7 @@ const util = {
return match;
});

// Use minimist to parse the args.
// Use argParser to parse the args.
const parsedArgs = this.parseArgs(passedArgs, types);

function validateArg(arg, cmdArg) {
Expand Down
4 changes: 2 additions & 2 deletions lib/vorpal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var VorpalUtil = require('./util');
var ui = require('./ui');
var Session = require('./session');
var intercept = require('./intercept');
var minimist = require('minimist');
var argParser = require('yargs-parser');
var commons = require('./vorpal-commons');
var chalk = require('chalk');
var os = require('os');
Expand Down Expand Up @@ -161,7 +161,7 @@ Vorpal.prototype.parse = function (argv, options) {
args.shift();
if (args.length > 0 || catchExists) {
if (options.use === 'minimist') {
result = minimist(args);
result = argParser(args);
} else {
// Wrap the spaced args back in quotes.
for (let i = 0; i < args.length; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
"inquirer": "0.11.0",
"lodash": "^4.5.1",
"log-update": "^1.0.2",
"minimist": "^1.2.0",
"node-localstorage": "^0.6.0",
"strip-ansi": "^3.0.0",
"wrap-ansi": "^2.0.0"
"wrap-ansi": "^2.0.0",
"yargs-parser": "^10.1.0"
},
"engines": {
"node": ">= 0.10.0",
Expand Down