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

executive

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

executive - npm Package Compare versions

Comparing version 1.0.8 to 1.1.1

67

lib/exec.js
// Generated by CoffeeScript 1.10.0
var BufferStream, Stream, error, parse, spawn,
var BufferStream, Stream, logError, once, parse, readPkgUp, ref, spawn,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

@@ -8,2 +8,4 @@ hasProp = {}.hasOwnProperty;

readPkgUp = require('read-pkg-up');
spawn = require('child_process').spawn;

@@ -13,3 +15,3 @@

error = require('./utils').error;
ref = require('./utils'), logError = ref.logError, once = ref.once;

@@ -48,13 +50,17 @@ BufferStream = (function(superClass) {

module.exports = function(cmd, opts, cb) {
var args, child, done, ref, stderr, stdout;
ref = parse(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2];
if (opts.stdio == null) {
opts.stdio = [0, 'pipe', 'pipe'];
}
var args, child, done, exit, ref1, ref2, ref3, ref4, stderr, stdout;
ref1 = parse(cmd, opts), cmd = ref1[0], args = ref1[1], opts = ref1[2];
stderr = new BufferStream();
stdout = new BufferStream();
child = spawn(cmd, args, opts);
child = spawn(cmd, args, {
cwd: opts.cwd,
env: opts.env,
stdio: (ref2 = opts.stdio) != null ? ref2 : [0, 'pipe', 'pipe'],
detached: opts.detached,
uid: opts.uid,
gid: opts.gid
});
child.setMaxListeners(0);
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
child.stdout.setEncoding((ref3 = opts.encoding) != null ? ref3 : 'utf8');
child.stderr.setEncoding((ref4 = opts.encoding) != null ? ref4 : 'utf8');
if (!opts.interactive) {

@@ -68,27 +74,32 @@ child.stdout.pipe(stdout);

}
done = function(err) {
done = once(function(err, status) {
stdout.destroy();
stderr.destroy();
child.kill();
stdout = stdout.toString();
stderr = stderr.toString();
if (err != null) {
err.stderr = stderr.toString();
err.stdout = stdout.toString();
error(err);
err.cmd = cmd;
err.args = args;
err.stdout = stdout;
err.stderr = stderr;
err.status = status;
if (!opts.quiet) {
logError(err);
}
}
child.kill();
stderr.destroy();
stdout.destroy();
return cb(err, stdout.toString(), stderr.toString());
};
child.on('error', function(err) {
err.cmd = cmd;
return done(err);
return cb(err, stdout, stderr, status);
});
child.on('close', function(code) {
exit = once(function(status, signal) {
var err;
err = null;
if (code !== 0) {
err = new Error(cmd + " exited with code " + code);
err.cmd = cmd + " " + (args.join(''));
err.code = code;
if (status !== 0) {
err = new Error("Command failed, '" + cmd + "' exited with status " + status);
err.signal = signal;
}
return done(err);
return done(err, status);
});
child.on('close', exit);
child.on('exit', exit);
child.on('error', done);
return child;

@@ -95,0 +106,0 @@ };

@@ -8,11 +8,20 @@ // Generated by CoffeeScript 1.10.0

logError = (require('./utils')).error;
logError = require('./utils').logError;
module.exports = function(cmd, opts, cb) {
var args, error, output, pid, ref, ref1, signal, status, stderr, stdout;
var args, error, output, pid, ref, ref1, ref2, ref3, signal, status, stderr, stdout;
ref = parse(cmd, opts), cmd = ref[0], args = ref[1], opts = ref[2];
if (opts.stdio == null) {
opts.stdio = [0, 'pipe', 'pipe'];
}
ref1 = spawnSync(cmd, args, opts), pid = ref1.pid, output = ref1.output, stdout = ref1.stdout, stderr = ref1.stderr, status = ref1.status, signal = ref1.signal, error = ref1.error;
ref3 = spawnSync(cmd, args, {
cwd: opts.cwd,
input: opts.input,
stdio: (ref1 = opts.stdio) != null ? ref1 : [0, 'pipe', 'pipe'],
env: opts.env,
uid: opts.uid,
gid: opts.gid,
timeout: opts.timeout,
killSignal: opts.killSignal,
maxBuffer: opts.maxBuffer,
encoding: (ref2 = opts.encoding) != null ? ref2 : 'utf8'
}), pid = ref3.pid, output = ref3.output, stdout = ref3.stdout, stderr = ref3.stderr, status = ref3.status, signal = ref3.signal, error = ref3.error;
opts;
if (!opts.quiet) {

@@ -22,15 +31,24 @@ process.stdout.write(stdout);

}
if (!((error != null) || status !== 0)) {
error = new Error("Command failed, '" + cmd + "' exited with status " + status);
}
if (error != null) {
error.code = status;
error.status = status;
error.pid = pid;
error.signal = signal;
error.pid = pid;
error.stderr = stderr;
error.stdout = stdout;
error.stderr = stderr;
if (error != null) {
if (!opts.quiet) {
logError(error);
}
}
return cb(error, stdout, stderr);
cb(error, stdout, stderr, status);
return {
status: status,
stderr: stderr,
stdout: stdout,
error: error
};
};
//# sourceMappingURL=execSync.js.map

@@ -40,22 +40,24 @@ // Generated by CoffeeScript 1.10.0

err = '';
flow(executor, cmds, opts, function(err, stdout, stderr) {
if (err != null) {
return flow(executor, cmds, opts, function(err, stdout, stderr, status) {
if (!opts.syncThrows) {
return;
}
if (opts.strict && status !== 0) {
throw err;
} else if ((err != null) && (status == null)) {
throw err;
}
out = stdout;
return err = stderr;
});
return {
stdout: out,
stderr: err
};
}
return new Promise(function(resolve, reject) {
return flow(executor, cmds, opts, function(err, stdout, stderr) {
if (err != null) {
return flow(executor, cmds, opts, function(err, stdout, stderr, status) {
if (opts.strict && status !== 0) {
return reject(err);
} else if ((err != null) && (status == null)) {
return reject(err);
}
return resolve({
stdout: stdout,
stderr: stderr
stderr: stderr,
status: status
});

@@ -62,0 +64,0 @@ });

// Generated by CoffeeScript 1.10.0
exports.serial = function(fn, cmds, opts, cb) {
var errAll, next, outAll;
var errAll, lastStatus, next, outAll;
outAll = '';
errAll = '';
lastStatus = null;
return (next = function() {
if (cmds.length) {
return fn(cmds.shift(), opts, function(err, stdout, stderr) {
return fn(cmds.shift(), opts, function(err, stdout, stderr, status) {
outAll += stdout;
errAll += stderr;
lastStatus = status;
if (err != null) {
return cb(err, outAll, errAll);
return cb(err, outAll, errAll, lastStatus);
}

@@ -17,3 +19,3 @@ return next();

} else {
return cb(null, outAll, errAll);
return cb(null, outAll, errAll, lastStatus);
}

@@ -31,7 +33,7 @@ })();

cmd = cmds[i];
results.push(fn(cmd, opts, function(err, stdout, stderr) {
results.push(fn(cmd, opts, function(err, stdout, stderr, status) {
outAll += stdout;
errAll += stderr;
if (++done === cmds.length) {
return cb(null, outAll, errAll);
return cb(null, outAll, errAll, status);
}

@@ -38,0 +40,0 @@ }));

// Generated by CoffeeScript 1.10.0
exports.error = function(err) {
if (err.code === 'ENOENT') {
return console.error("ExecutiveError: " + err.syscall + " " + err.code);
exports.logError = function(err) {
if ((err.code === 'ENOENT') && /^spawn/.test(err.syscall)) {
console.error("Error: " + err.code + ", " + err.syscall);
return console.error("Make sure '" + err.cmd + "' exists and is executable.");
}

@@ -22,2 +23,17 @@ };

exports.once = function(fn) {
var ran, result;
ran = false;
result = null;
return function() {
if (ran) {
return result;
}
ran = true;
result = fn.apply(this, arguments);
fn = null;
return result;
};
};
//# sourceMappingURL=utils.js.map
{
"name": "executive",
"version": "1.0.8",
"version": "1.1.1",
"description": "Elegant command execution.",

@@ -37,3 +37,3 @@ "main": "lib/",

"postmortem": "^0.2.3",
"shortcake": "^1.0.0",
"shortcake": "^1.0.3",
"vigil": "^0.5.7"

@@ -40,0 +40,0 @@ },

@@ -96,3 +96,4 @@ # executive [![Build Status](https://travis-ci.org/zeekay/executive.svg?branch=master)](https://travis-ci.org/zeekay/executive) [![npm version](https://badge.fury.io/js/executive.svg)](https://badge.fury.io/js/executive)

If you'd prefer not to pipe `stdin`, `stdout`, `stderr` set `quiet` to `false`:
If you'd prefer not to pipe `stdout` and `stderr` set `quiet` to `true`:
```javascript

@@ -116,3 +117,11 @@ exec.quiet(['ls', 'ls'], function(err, stdout, stderr) {

#### options.strict
##### default `false`
Any non-zero exit status is treated as an error. Promises will be rejected and
an error will be thrown with `exec.sync` if `syncThrows` is enabled.
#### options.syncThrows
##### default `false`
Will cause `exec.sync` to throw errors rather than returning them.
## Extra

@@ -119,0 +128,0 @@ Great with `cake`, `grunt`, `gulp` and other task runners. Even better mixed

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