🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

capitano

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capitano - npm Package Compare versions

Comparing version

to
1.6.0

.hound.yml

42

build/command.js

@@ -1,2 +0,2 @@

var Command, Option, Signature, parse, settings, state, _;
var Command, Option, Signature, parse, settings, state, utils, _;

@@ -17,2 +17,4 @@ _ = require('lodash');

utils = require('./utils');
module.exports = Command = (function() {

@@ -56,2 +58,10 @@ function Command(options) {

Command.prototype._checkElevation = function(callback) {
if (this.root != null) {
return utils.isElevated(callback);
} else {
return callback(null, true);
}
};
Command.prototype.execute = function(args, callback) {

@@ -63,20 +73,28 @@ if (args == null) {

return function(error, params) {
var parsedOptions;
if (error != null) {
return typeof callback === "function" ? callback(error) : void 0;
}
parsedOptions = _this._parseOptions(args.options);
return _this.applyPermissions(function(error) {
return _this._checkElevation(function(error, isElevated) {
var parsedOptions;
if (error != null) {
return typeof callback === "function" ? callback(error) : void 0;
}
try {
_this.action(params, parsedOptions, callback);
} catch (_error) {
error = _error;
return typeof callback === "function" ? callback(error) : void 0;
if (_this.root && !isElevated) {
return callback(new Error('You need admin privileges to run this command'));
}
if (_this.action.length < 3) {
return typeof callback === "function" ? callback() : void 0;
}
parsedOptions = _this._parseOptions(args.options);
return _this.applyPermissions(function(error) {
if (error != null) {
return typeof callback === "function" ? callback(error) : void 0;
}
try {
_this.action(params, parsedOptions, callback);
} catch (_error) {
error = _error;
return typeof callback === "function" ? callback(error) : void 0;
}
if (_this.action.length < 3) {
return typeof callback === "function" ? callback() : void 0;
}
});
});

@@ -83,0 +101,0 @@ };

@@ -1,5 +0,9 @@

var stdin;
var isElevated, stdin;
stdin = require('get-stdin');
isElevated = require('is-elevated');
exports.getStdin = stdin;
exports.isElevated = isElevated;
{
"name": "capitano",
"version": "1.5.0",
"version": "1.6.0",
"description": "Powerful, non opitionated command line parser for serious applications",

@@ -43,2 +43,3 @@ "main": "build/capitano.js",

"get-stdin": "^4.0.1",
"is-elevated": "^1.0.0",
"lodash": "~2.4.1",

@@ -45,0 +46,0 @@ "minimist": "~1.1.0",

@@ -107,2 +107,6 @@ Capitano

### root (boolean)
If you specify this option to true, then the command will only be runnable by a user with admin privileges, or prefixed by `sudo`.
## capitano.globalOption(options)

@@ -144,2 +148,8 @@

This is also the command you need to use if you need to call a command from another command. For example:
```coffee
capitano.run('my other command --foo bar', callback)
```
**Note:** `capitano.run` is a shorcut function for `capitano.execute(capitano.parse(argv), callback)`. You will usually use this function, however you can use `parse()` and `execute()` in particular situations when you need to differenciate between parsing and executing the commands.

@@ -420,2 +430,6 @@

### 1.6.0
- Implement root property support.
### 1.5.0

@@ -422,0 +436,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet