checkcommand
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,3 +0,7 @@ | ||
var utils; | ||
var Promise, utils, _; | ||
_ = require('lodash'); | ||
Promise = require('bluebird'); | ||
utils = require('./utils'); | ||
@@ -29,1 +33,25 @@ | ||
}; | ||
/** | ||
* @summary Ensure multiple commands at the same time. | ||
* @function | ||
* @public | ||
* | ||
* @param {Object} commands - commands | ||
* @returns {Promise} | ||
* | ||
* @example | ||
* checkcommand.ensureMultiple | ||
* 'wget': 'Missing wget' | ||
* 'curl': 'Missing curl' | ||
* 'axel': 'Missing axel' | ||
*/ | ||
exports.ensureMultiple = function(commands, callback) { | ||
var ensurePromises; | ||
ensurePromises = _.map(_.pairs(commands), function(command) { | ||
return exports.ensure(_.first(command), _.last(command)); | ||
}); | ||
return Promise.all(ensurePromises).nodeify(callback); | ||
}; |
{ | ||
"name": "checkcommand", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Check that a command exists", | ||
@@ -41,4 +41,5 @@ "main": "build/checkcommand.js", | ||
"bluebird": "^2.9.30", | ||
"command-exists": "^0.1.0" | ||
"command-exists": "^0.1.0", | ||
"lodash": "^3.9.3" | ||
} | ||
} |
@@ -64,2 +64,37 @@ checkcommand | ||
### checkcommand.ensureMultiple(Object commands[, Function callback]) | ||
Ensure multiple commands. A utility function to prevent calling `checkcommand.ensure()` multiple times. | ||
The `commands` object contains command names as property keys, and error messages as values. | ||
Example: | ||
```coffee | ||
checkcommand = require('checkcommand') | ||
checkcommand.ensureMultiple | ||
'wget': 'Missing wget' | ||
'curl': 'Missing curl' | ||
.then -> | ||
console.log('It seems that wget and curl are installed!') | ||
.catch (error) -> | ||
console.error(error) | ||
``` | ||
*** | ||
```coffee | ||
checkcommand = require('checkcommand') | ||
checkcommand.ensureMultiple | ||
'wget': 'Missing wget' | ||
'curl': 'Missing curl' | ||
, (error) -> | ||
if error? | ||
console.error(error.message) | ||
else | ||
console.log('It seems that wget and curl are installed!') | ||
``` | ||
Tests | ||
@@ -66,0 +101,0 @@ ----- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17886
16
197
129
3
+ Addedlodash@^3.9.3
+ Addedlodash@3.10.1(transitive)