Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
deferred-exec
Advanced tools
Deferred based tool to run exec commands
Install the module with: npm install deferred-exec
or add it to your project's package.json
file.
You can also clone this repo and npm install folderOfClonedRepo
to get a branch or development copy.
All calls return a promise, which means it's easy to do stuff when they complete or fail:
var dexec = require( 'deferred-exec' );
dexec( 'echo "yay"' ).done( function( stdout, stderr, command ) {
console.log( stdout ); // logs "yay"
});
Since they are deferreds, you can pass them around in your code:
var dexec = require( 'deferred-exec' );
var command = dexec( 'echo "gotcha"' );
doSomethingWithCommand( command );
// meanwhile, in some other part of your application
function doSomethingWithCommand( command ) {
command.done( function( stdout, stderr, command ) {
console.log( 'just ran', command, 'and got', stdout );
});
}
Use Underscore.Deferred if you want to use
_.when
to group multiple commands. (Note: you can use underscore.deferred with lodash)
var dexec = require( 'deferred-exec' );
// require and mixin lodash with _.deferred
var _ = require( 'lodash' );
_.mixin( require( 'underscore.deferred' ) );
var commandA = dexec( 'ls /etc' );
var commandB = dexec( 'echo "hi"' );
// when both commands succeed
_.when( commandA, commandB ).done( function( a, b ){
console.log( 'commandA output:', a[0] );
console.log( 'commandB output:', b[0] );
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Copyright (c) 2012 Dan Heberden
Licensed under the MIT license.
FAQs
Deferred based tool to run exec commands
The npm package deferred-exec receives a total of 11 weekly downloads. As such, deferred-exec popularity was classified as not popular.
We found that deferred-exec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.