New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cmd-fn

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmd-fn - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

51

index.js

@@ -9,2 +9,20 @@ #! /usr/bin/env node

function resolve(val) {
try {
console.log(JSON.stringify(val));
} catch (e) {
console.log(val);
}
process.exit(0);
}
function reject(val) {
try {
console.error(JSON.stringify(val));
} catch (e) {
console.error(val);
}
process.exit(0);
}
program

@@ -16,2 +34,4 @@ .usage('[options]')

.option('-p, --params [arguments]', 'function arguments specified as an array e.g.: `\'["foo", "bar"]\'`', jsonArgs)
.option('--promise', 'function is async and uses promises')
.option('--node-callback', 'function is async with a node-style callback')
.on('--help', function(){

@@ -23,2 +43,5 @@ console.log(' Example:');

console.log('');
console.log(' To do an async call like `http.get({"hostname":"www.google.com"}, cb)`:');
console.log(' $ cmd-fn --module http --function get --params \'[{"hostname":"www.google.com"}]\' --node-callback');
console.log('');
})

@@ -34,3 +57,3 @@ .parse(process.argv);

if (!program.module) {
console.error("Module option (`--module`) is required");
console.error('Module option (`--module`) is required');
process.exit(0);

@@ -53,5 +76,29 @@ }

}
if (program.nodeCallback) {
if (!program.params) {
program.params = [];
}
program.params.push(function(err, val) {
console.log(err, val);
if (err) {
reject(err);
} else {
resolve(val);
}
});
}
console.log(program.params[1].toString());
returnVal = func$.apply(func$, program.params);
}
console.log(JSON.stringify(returnVal));
if (program.promise) {
returnVal.then(function(val) {
resolve(val);
}, function(err) {
reject(err);
});
} else if(program.nodeCallback) {
// Wait for callback
} else {
resolve(returnVal);
}

2

package.json
{
"name": "cmd-fn",
"version": "1.0.0",
"version": "1.1.0",
"repository": "git://github.com/davej/cmd-fn",

@@ -5,0 +5,0 @@ "description": "Execute any node module function from the command line.",

@@ -24,2 +24,4 @@ cmd-fn

-p, --params [arguments] function arguments specified as an array e.g.: `'["foo", "bar"]'`
--promise function is async and uses promises
--node-callback function is async with a node-style callback

@@ -30,2 +32,5 @@ Example:

$ cmd-fn --module fs --function readdirSync --params '["/var/tmp"]'
To do an async call like `http.get({"hostname":"www.google.com"}, cb)`:
$ cmd-fn --module http --function get --params '[{"hostname":"www.google.com"}]' --node-callback
```

@@ -32,0 +37,0 @@

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