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

deferred-exec

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deferred-exec

Deferred based tool to run exec commands

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by9.09%
Maintainers
1
Weekly downloads
 
Created
Source

deferred-exec

Deferred based tool to run exec commands

Installing

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.

Using

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] );
});

Contributing

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.

License

Copyright (c) 2012 Dan Heberden
Licensed under the MIT license.

FAQs

Package last updated on 18 Sep 2012

Did you know?

Socket

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.

Install

Related posts

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