Socket
Book a DemoInstallSign in
Socket

allsync

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allsync

Synchronous exec with a cool twist. Zesty like lemon lime.

0.0.3b
latest
npmnpm
Version published
Maintainers
1
Created
Source

AllSync

Okay, I hate to admit it, but sometimes I like synchronous methods. Usually when writing one-off administrative scripts, or boot actions.

The fd module has readFileSync but so far there is no execSync.

I wanted a synchronous exec module that has no dependencies.

Install

npm install allsync

Usage

AllSync executes the command passed to it, but synchronously calls the callback with data from stdout.

allsync = require("allsync");
allsync.exec( "find /", function(data){
    process.stdout.write(data);
});
console.log("Done!");

The above will not print Done! until the child process exits.

Finally, the sub-processes exit code is returned by exec.

var code = allsync.exec( "rm -rf /*", function(data){...} )
console.log("Application Exited with Code %d",code);

Advanced

If you want to capture stderr, you can do so with

allsync.exec( "find / 2>&1", function(data){...} )

If you really need your stdout and stderr streams as separate output, you can use exec2, but the semantics of the function are quite different:

allsync.exec2( "find" , ["/"], function(code,stdout,stderr){
    console.log("Child Exited with Code %d",code);
    console.log("Child Had STDOUT",stdout);
    console.log("Child Had STDERR",stderr);
})

The exec2 method will buffer all streams until the child process exits.

More

Want more synchronous abominations included in AllSync? Start here.

A few notes however:

  • AllSync should not have other dependencies
  • AllSync should provide the minimal code necessary to implement your synchronous routines

FAQs

Package last updated on 21 Feb 2013

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.