Huge News!Announcing our $40M Series B led by Abstract Ventures.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 0.4.7 to 0.4.8

.travis.yml

74

index.js

@@ -1,20 +0,22 @@

var child_process = require('child_process'),
var childProcess = require('child_process'),
isWin = /^win/.test(process.platform),
path = require('path'),
Stream = require('stream');
Stream = require('stream'),
shellQuote = require('shell-quote');
function parseShell(s) {
if (!s) return;
var parseShell = function(s) {
var args = shellQuote.parse(s);
for (var i=0; i<args.length; i++) {
var arg = args[i];
return s.match(/(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g).map(function(s) {
if (/^'/.test(s)) {
return s.replace(/^'|'$/g, '')
.replace(/\\(["'\\$`(){}!#&*|])/g, '$1');
} else if (/^"/.test(s)) {
return s.replace(/^"|"$/g, '')
.replace(/\\(["'\\$`(){}!#&*|])/g, '$1');
} else {
return s.replace(/\\([ "'\\$`(){}!#&*|])/g, '$1');
// Only process env variables
if (arg.indexOf('=') == -1) {
continue
}
});
// Ensure env variable is properly quoted
arg = arg.split('=', 2);
args[i] = arg[0] + '=' + shellQuote.quote([arg[1]])
}
return args;
}

@@ -30,3 +32,3 @@

// stream to capture stdout
stdout = new Stream();
var stdout = new Stream();
stdout.writable = true;

@@ -48,3 +50,3 @@

// stream to capture stderr
stderr = new Stream();
var stderr = new Stream();
stderr.writable = true;

@@ -67,3 +69,3 @@

var child = child_process.spawn(cmd, args, opts);
var child = childProcess.spawn(cmd, args, opts);

@@ -107,3 +109,3 @@ child.on('error', function(err) {

var child = child_process.spawn(cmd, args, opts);
var child = childProcess.spawn(cmd, args, opts);

@@ -132,3 +134,3 @@ child.on('error', function(err) {

var child = child_process.spawn(cmd, args, opts);
var child = childProcess.spawn(cmd, args, opts);

@@ -170,3 +172,3 @@ child.on('error', function(err) {

function exec(args, opts, callback) {
var env = {}, e, cmd, arg;
var env = {}, e, cmd;

@@ -178,30 +180,14 @@ // Copy enviromental variables from process.env.

if (typeof args === 'string') {
// Reverse arguments, javascript does not support lookbehind assertions so
// we'll use a lookahead assertion instead in our regex later.
args = args.split('').reverse().join('');
// Split on whitespace, respecting escaped spaces.
args = args.split(/\s+(?!\\)/g);
// Correct order of arguments.
args.reverse();
args = parseShell(args);
// Correct order of characters, removing escapes
for (var i=0; i<args.length; i++) {
args[i] = args[i].split('').reverse().join('').replace('\\ ', ' ');
}
while (cmd = args.shift()) {
// Check if this is an enviromental variable
if (cmd.indexOf('=') == -1) {
break;
}
// Parse out command and any enviromental variables
while ((cmd = args.shift()).indexOf('=') != -1) {
e = cmd.split('=');
if (e.length != 2)
throw new Error('Invalid enviromental variable specified.');
// Save env variable
e = cmd.split('=', 2);
env[e[0]] = e[1];
if (args.length === 0)
throw new Error('No command specified.');
}
if (args.length) args = parseShell(args.join(' '));
} else {

@@ -208,0 +194,0 @@ // Here args should be an object.

{
"name": "executive",
"version": "0.4.7",
"version": "0.4.8",
"description": "Elegant command execution.",

@@ -25,9 +25,17 @@ "main": "index.js",

],
"author": "Zach Kelling <zk@monoid.io> (http://monoid.io)",
"license": "BSD",
"author": "Zach Kelling <zk@monoid.io> (http://zeekay.io)",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/zeekay/executive/blob/master/LICENSE"
}
],
"readmeFilename": "README.md",
"devDependencies": {
"chai": "~1.6.0",
"mocha": "~1.9.0"
"chai": "^2.0.0",
"mocha": "^2.1.0"
},
"dependencies": {
"shell-quote": "^1.4.3"
}
}

@@ -1,2 +0,2 @@

# executive
# executive [![Build Status](https://travis-ci.org/zeekay/executive.svg?branch=master)](https://travis-ci.org/zeekay/executive)

@@ -3,0 +3,0 @@ An easy to use wrapper around `child_process.spawn`, useful for Cakefiles and the like. Pipes `stdout`, `stderr` and `stdin` so you don't have to. Think of it as a streaming `child_process.exec` with a few extra goodies.

@@ -70,5 +70,5 @@ exec = require('../');

it('should understand quoted long options', function() {
exec.parseShell('--long-arg="one two three"').should.contain('--long-arg="one two three"');
exec.parseShell('--long-arg="one two three"').should.contain("--long-arg=\'one two three\'");
});
});
});
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