Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

optimist

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimist - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

34

index.js

@@ -127,16 +127,28 @@ module.exports = Argv;

else if (arg.match(/^-[^-]+/)) {
arg.slice(1,-1).split('').forEach(function (letter) {
set(letter, true);
});
var letters = arg.slice(1,-1).split('');
var key = arg.slice(-1)[0];
var broken = false;
for (var j = 0; j < letters.length; j++) {
if (letters[j+1] && letters[j+1].match(/\W/)) {
set(letters[j], arg.slice(j+2));
broken = true;
break;
}
else {
set(letters[j], true);
}
}
if (args[i+1] && !args[i+1].match(/^-/)
&& !flags.bools[key]) {
set(key, args[i+1]);
i++;
if (!broken) {
var key = arg.slice(-1)[0];
if (args[i+1] && !args[i+1].match(/^-/)
&& !flags.bools[key]) {
set(key, args[i+1]);
i++;
}
else {
set(key, true);
}
}
else {
set(key, true);
}
}

@@ -143,0 +155,0 @@ else {

{
"name" : "optimist",
"version" : "0.1.8",
"version" : "0.1.9",
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.",

@@ -5,0 +5,0 @@ "main" : "./index.js",

var optimist = require('optimist');
var assert = require('assert');
exports['short boolean'] = function (assert) {
exports['short boolean'] = function () {
var parse = optimist.parse([ '-b' ]);

@@ -10,3 +10,3 @@ assert.eql(parse, { b : true, _ : [], $0 : 'expresso' });

exports['long boolean'] = function (assert) {
exports['long boolean'] = function () {
assert.eql(

@@ -18,3 +18,3 @@ optimist.parse([ '--bool' ]),

exports.bare = function (assert) {
exports.bare = function () {
assert.eql(

@@ -26,3 +26,3 @@ optimist.parse([ 'foo', 'bar', 'baz' ]),

exports['short group'] = function (assert) {
exports['short group'] = function () {
assert.eql(

@@ -34,3 +34,3 @@ optimist.parse([ '-cats' ]),

exports['short group next'] = function (assert) {
exports['short group next'] = function () {
assert.eql(

@@ -42,3 +42,3 @@ optimist.parse([ '-cats', 'meow' ]),

exports['short capture'] = function (assert) {
exports['short capture'] = function () {
assert.eql(

@@ -50,3 +50,3 @@ optimist.parse([ '-h', 'localhost' ]),

exports['short captures'] = function (assert) {
exports['short captures'] = function () {
assert.eql(

@@ -58,3 +58,3 @@ optimist.parse([ '-h', 'localhost', '-p', '555' ]),

exports['long capture sp'] = function (assert) {
exports['long capture sp'] = function () {
assert.eql(

@@ -66,3 +66,3 @@ optimist.parse([ '--pow', 'xixxle' ]),

exports['long capture eq'] = function (assert) {
exports['long capture eq'] = function () {
assert.eql(

@@ -74,3 +74,3 @@ optimist.parse([ '--pow=xixxle' ]),

exports['long captures sp'] = function (assert) {
exports['long captures sp'] = function () {
assert.eql(

@@ -82,3 +82,3 @@ optimist.parse([ '--host', 'localhost', '--port', '555' ]),

exports['long captures eq'] = function (assert) {
exports['long captures eq'] = function () {
assert.eql(

@@ -90,3 +90,3 @@ optimist.parse([ '--host=localhost', '--port=555' ]),

exports['mixed short bool and capture'] = function (assert) {
exports['mixed short bool and capture'] = function () {
assert.eql(

@@ -101,3 +101,3 @@ optimist.parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),

exports['short and long'] = function (assert) {
exports['short and long'] = function () {
assert.eql(

@@ -112,3 +112,3 @@ optimist.parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),

exports.no = function (assert) {
exports.no = function () {
assert.eql(

@@ -120,3 +120,3 @@ optimist.parse([ '--no-moo' ]),

exports.multi = function (assert) {
exports.multi = function () {
assert.eql(

@@ -128,3 +128,3 @@ optimist.parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),

exports.comprehensive = function (assert) {
exports.comprehensive = function () {
assert.eql(

@@ -156,3 +156,3 @@ optimist.parse([

exports.nums = function (assert) {
exports.nums = function () {
var argv = optimist.parse([

@@ -183,3 +183,3 @@ '-x', '1234',

exports['flag boolean'] = function (assert) {
exports['flag boolean'] = function () {
var parse = optimist([ '-t', 'moo' ]).boolean(['t']).argv;

@@ -190,3 +190,3 @@ assert.eql(parse, { t : true, _ : [ 'moo' ], $0 : 'expresso' });

exports['boolean groups'] = function (assert) {
exports['boolean groups'] = function () {
var parse = optimist([ '-x', '-z', 'one', 'two', 'three' ])

@@ -217,1 +217,12 @@ .boolean(['x','y','z']).argv;

};
exports.slashBreak = function () {
assert.eql(
optimist.parse([ '-I/foo/bar/baz' ]),
{ I : '/foo/bar/baz', _ : [], $0 : 'expresso' }
);
assert.eql(
optimist.parse([ '-xyz/foo/bar/baz' ]),
{ x : true, y : true, z : '/foo/bar/baz', _ : [], $0 : 'expresso' }
);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc