Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exec-extra

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exec-extra - npm Package Compare versions

Comparing version 2.2.4 to 2.3.0

lib/spawn-async.js

7

index.js

@@ -0,5 +1,6 @@

'use strict';
var isWindows = require('is-windows');
if(isWindows()) {
require('git-bash-shell');
if (isWindows()) {
require('git-bash-shell')();
} else {

@@ -11,2 +12,2 @@ require('./lib/patch');

module.exports = require('./lib/exec-async');
module.exports = require('./lib/spawn-async');

@@ -0,13 +1,11 @@

'use strict';
var path = require('path');
var binPath = path.join('node_modules', '.bin');
var delimiter = path.delimiter;
var paths = process.env.PATH.split(delimiter);
[path.join('node_modules', '.bin'), 'bin'].forEach(function(path) {
if(paths.indexOf(path) < 0 ) {
paths.unshift(path);
}
});
var paths = process.env.PATH.split(delimiter).filter(Boolean);
paths.push(path.join(__dirname, '../bin'));
process.env.PATH = paths.filter(Boolean).join(delimiter);
if (paths.indexOf(binPath) < 0) {
paths.unshift(binPath);
process.env.PATH = paths.join(delimiter);
}

@@ -0,16 +1,33 @@

'use strict';
var path = require('path').posix;
var osHomedir = require('os-homedir');
var os = require('os');
function fixFn(object, fnName) {
function getHome (options) {
var homedir = options.envPairs.find(function (value) {
return /^HOME=/i.test(value);
});
return homedir && homedir.slice(5);
}
function fixSpawnArgs (options) {
if (/^~\//.test(options.file)) {
// 处理linux风格的home路径
options.file = path.join(getHome(options) || os.homedir(), options.file.slice(2));
}
}
function fixFn (object, fnName, argHook) {
var oldFn = object[fnName];
object[fnName] = function(options) {
if(/^~\//.test(options.file)) {
// 处理linux风格的home路径
options.file = path.join(osHomedir(), options.file.slice(2));
object[fnName] = function () {
var args = arguments;
try {
argHook.apply(this, args);
} catch (ex) {
//
}
return oldFn.call(this, options);
return oldFn.apply(this, args);
};
}
fixFn(require('child_process').ChildProcess.prototype, 'spawn');
fixFn(process.binding('spawn_sync'), 'spawn');
fixFn(require('child_process').ChildProcess.prototype, 'spawn', fixSpawnArgs);
fixFn(process.binding('spawn_sync'), 'spawn', fixSpawnArgs);

@@ -10,5 +10,4 @@ {

"dependencies": {
"is-windows": "^1.0.0",
"os-homedir": "^1.0.2",
"thenify": "^3.2.1"
"is-windows": "^1.0.1",
"spawn-promise": "^0.1.7"
},

@@ -18,9 +17,15 @@ "description": "A better child_process",

"any-promise": "^1.3.0",
"codecov": "^3.0.0",
"cover": "^0.2.9",
"coveralls": "^2.11.15",
"eslint": "^3.12.2",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"mz": "^2.6.0",
"node-version-check": "^2.1.1"
"coveralls": "^3.0.0",
"eslint": "^4.17.0",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^6.0.0",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"expect.js": "^0.3.1",
"mocha": "^5.0.0",
"mz": "^2.7.0",
"nyc": "^11.4.1"
},

@@ -44,3 +49,2 @@ "directories": {

"spawn",
"sudo",
"where",

@@ -52,5 +56,11 @@ "which"

"name": "exec-extra",
"nyc": {
"reporter": [
"lcov",
"text-summary"
],
"cache": true
},
"optionalDependencies": {
"git-bash-shell": "^1.2.0",
"runas": "^3.1.1"
"git-bash-shell": "^1.4.0"
},

@@ -62,8 +72,7 @@ "repository": {

"scripts": {
"coveralls": "npm run test-cov && coveralls < coverage/lcov.info",
"lint": "node-version-gte-4 && eslint lib || echo \"ESLint not supported\"",
"test": "npm run lint && mocha",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha"
"report-coverage": "codecov",
"pretest": "eslint lib test *.js",
"test": "nyc mocha --no-timeouts"
},
"version": "2.2.4"
"version": "2.3.0"
}

@@ -7,3 +7,3 @@ exec-extra

[![AppVeyor](https://img.shields.io/appveyor/ci/gucong3000/exec-extra.svg?&label=Windows)](https://ci.appveyor.com/project/gucong3000/exec-extra)
[![Coverage Status](https://img.shields.io/coveralls/gucong3000/exec-extra.svg)](https://coveralls.io/r/gucong3000/exec-extra)
[![Codecov](https://img.shields.io/codecov/c/github/gucong3000/exec-extra.svg)](https://codecov.io/gh/gucong3000/exec-extra)

@@ -15,6 +15,8 @@ A better child_process

- Executes locally installed binaries by name.
- Support [bash](https://pt.wikipedia.org/wiki/Bash) shell cross platform
- Support [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)) shell script cross platform
- Support [POSIX](https://en.wikipedia.org/wiki/POSIX) file path.
- Improved Windows support.
- Support [Shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))
- Support [PATHEXT](https://github.com/joyent/node/issues/2318)
- Support [shebangs](http://pt.wikipedia.org/wiki/Shebang)
- Support [Shell script](https://en.wikipedia.org/wiki/Shell_script)

@@ -31,6 +33,11 @@ ## Install

const exec = require('exec-extra');
exec('cat', ['README.md']).then(([stdout, stderr]) => {
console.log(stdout);
console.error(stderr);
});
exec('cat', ['README.md']).then((stdout) => {
console.info('Success!')
console.info('stdout:', stdout.toString())
})
.catch((error) => {
console.error('Failed!')
console.error('exit status:', error.exitStatus)
console.error('stderr:', error.stderr.toString())
})
```

@@ -37,0 +44,0 @@

Sorry, the diff of this file is not supported yet

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