Skip to content

EmingK/spawn-sync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spawn-sync

Polyfill for child_process.spawnSync.

On iojs and node >= 0.12 it will just export the built in child_process.spawnSync. On platforms that support compiling native modules it uses the execSync module to get true synchronous execution. If native compilation is not supported it falls back to waiting for an output file to exist in a tight loop. In this way it gains excellent cross platform support, but don't expect it to be efficient on all platforms.

Linux & OSX Tests Status Windows Tests Status Dependency Status NPM version

Installation

npm install spawn-sync

Usage

var spawnSync = require('spawn-sync');

var result = spawnSync('node',
                       ['filename.js'],
                       {input: 'write this to stdin'});

// Note, status code will always equal 0 if using busy waiting fallback
if (result.status !== 0) {
  process.stderr.write(result.stderr);
  process.exit(result.status);
} else {
  process.stdout.write(result.stdout);
  process.stderr.write(result.stderr);
}

License

MIT

About

Prollyfill v0.12 spawnSync method

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%