Socket
Socket
Sign inDemoInstall

main

Package Overview
Dependencies
8
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.23 to 0.0.24

.jshintrc

15

examples/arguments.js

@@ -17,12 +17,19 @@ #!/usr/bin/env node

//get all positional arguments:
$.cout($.args);
$.cout('args', $.args);
// all flag values (NOTE that this object does not have alias indexes)
$.cout($.flags)
$.cout('flags', $.flags);
// specific positional arguments
$.cout( $(0), $(1), $(2) );
$.cout('positional', $(0), $(1), $(2) );
// specific flags (note that alias or full name can be used to get values)
$.cout( $('first'), $('m'), $('l') );
$.cout('specific flags', $('first'), $('m'), $('l') );
// we can also get a list of flags that the user specified that we did not
$.cout('extraFlags', $.extraFlags);
// we can also access them as well - try calling with this flag set
$.cout('extra specific flags', $('hello'));
});

@@ -37,3 +37,3 @@ #!/usr/bin/env node

$.mkdirSync(tempDir);
$.cout(tempDir)
$.cout(tempDir);

@@ -40,0 +40,0 @@ var file1 = $.mktemp({ dir: tempDir, suffix: '.txt' });

@@ -17,5 +17,10 @@ var when = require('when')

// Add in flags for optimist to parse
if (flags) {
for (var key in flags) {
self.optimist.options(key, flags[key]);
// if we have an alias, have
if (typeof flags[key].alias !== 'undefined') {
self.optimist.options(flags[key].alias, flags[key]);
}
}

@@ -30,10 +35,33 @@ }

// set `self.flag`s to the values parsed (skip over $0 / "_" / others)
// set `self.flags` to the values parsed (skip over $0 / "_" / others)
self.flags = {};
// extra flags not defined, but the user passed in anyway
self.extraFlags = {};
if (flags) {
for (var argvKey in self.optimist.argv) {
var argvKey, invalidArgvKey, aliasName, aliasValues = {};
// pass through and get the alias names (and load in flags)
for (argvKey in self.optimist.argv) {
if (typeof flags[argvKey] !== 'undefined') {
self.flags[argvKey] = self.optimist.argv[argvKey];
aliasName = flags[argvKey].alias;
if (typeof aliasName !== 'undefined') {
aliasValues[aliasName] = true;
}
}
}
// pass through again, and load in everything else ignoring alias'
for (argvKey in self.optimist.argv) {
// if if wasn't a defined alias, and isn't invalid then it's an
// extra flag
if (typeof flags[argvKey] === 'undefined' &&
typeof aliasValues[argvKey] === 'undefined' &&
argvKey !== '_' &&
argvKey !== '$0')
{
self.extraFlags[argvKey] = self.optimist.argv[argvKey];
}
}
}

@@ -165,3 +193,3 @@

if (typeof positionOrFlag === 'string') {
return self.optimist.argv[positionOrFlag]
return self.optimist.argv[positionOrFlag];
}

@@ -168,0 +196,0 @@ if (typeof positionOrFlag === 'number') {

{
"name": "main",
"version": "0.0.23",
"version": "0.0.24",
"main": "index.js",

@@ -14,5 +14,5 @@ "description": "Provides useful tools for writing command line scripts",

"dependencies": {
"optimist": "~0.6.0",
"temp": "~0.6.0",
"when": "~2.5.1"
"optimist": "~0.6.1",
"when": "~2.8.0",
"temp": "~0.6.0"
},

@@ -19,0 +19,0 @@ "scripts": {

@@ -12,2 +12,5 @@ "use strict";

/* global describe */
/* global it */
describe('tools', function() {

@@ -130,3 +133,3 @@

return tools.rm(folder);
})
});
});

@@ -142,3 +145,3 @@

return tools.rm(__dirname + '/foo');
})
});
});

@@ -145,0 +148,0 @@

@@ -12,2 +12,5 @@ "use strict";

/* global describe */
/* global it */
describe('toolsSync', function() {

@@ -14,0 +17,0 @@

@@ -14,7 +14,7 @@ "use strict";

if (typeof thing === 'object') {
try {
var json = prettify
? JSON.stringify(thing, null, 4)
try {
var json = prettify
? JSON.stringify(thing, null, 4)
: JSON.stringify(thing);
return json;
return json;
}

@@ -53,3 +53,3 @@ catch (e) {}

// Handle cases where user specifies root, e.g. /home/nolan/...
if (split[0] == '') {
if (split[0] === '') {
split.shift();

@@ -60,3 +60,3 @@ split[0] = path.sep + split[0];

split.reduce(function(previousPath, itemInPath) {
var newPath = path.join(previousPath, itemInPath)
var newPath = path.join(previousPath, itemInPath);
if (!exports.exists(newPath)) { fs.mkdirSync(newPath); }

@@ -97,3 +97,3 @@ return newPath;

exports.walk(filePath, true).reverse().forEach(function(file) {
fs.statSync(file).isDirectory()
return fs.statSync(file).isDirectory()
? fs.rmdirSync(file)

@@ -100,0 +100,0 @@ : fs.unlinkSync(file);

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc