foreground-child
Advanced tools
Comparing version 1.5.1 to 1.5.2
37
index.js
var signalExit = require('signal-exit') | ||
var spawn = require('child_process').spawn | ||
var crossSpawn = require('cross-spawn-async') | ||
var fs = require('fs') | ||
var which = require('which') | ||
function needsCrossSpawn (exe) { | ||
if (process.platform !== 'win32') { | ||
return false | ||
} | ||
try { | ||
exe = which.sync(exe) | ||
} catch (er) { | ||
// failure to find the file? cmd probably needed. | ||
return true | ||
} | ||
if (/\.(com|cmd|bat)$/i.test(exe)) { | ||
// need cmd.exe to run command and batch files | ||
return true | ||
} | ||
var buffer = new Buffer(150) | ||
try { | ||
var fd = fs.openSync(exe, 'r') | ||
fs.readSync(fd, buffer, 0, 150, 0) | ||
} catch (e) { | ||
// If it's not an actual file, probably it needs cmd.exe. | ||
// also, would be unsafe to test arbitrary memory on next line! | ||
return true | ||
} | ||
return /\#\!(.+)/i.test(buffer.toString().trim()) | ||
if (process.platform === 'win32') { | ||
spawn = require('cross-spawn') | ||
} | ||
@@ -69,4 +39,3 @@ | ||
var spawnfn = needsCrossSpawn(program) ? crossSpawn : spawn | ||
var child = spawnfn(program, args, spawnOpts) | ||
var child = spawn(program, args, spawnOpts) | ||
@@ -73,0 +42,0 @@ var childExited = false |
{ | ||
"name": "foreground-child", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.", | ||
@@ -10,5 +10,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"cross-spawn-async": "^2.1.1", | ||
"signal-exit": "^2.0.0", | ||
"which": "^1.2.1" | ||
"cross-spawn": "^4", | ||
"signal-exit": "^2.0.0" | ||
}, | ||
@@ -19,3 +18,5 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "tap --coverage test/*.js" | ||
"test": "tap --coverage test/*.js", | ||
"changelog": "bash changelog.sh", | ||
"postversion": "npm run changelog && git add CHANGELOG.md && git commit -m 'update changelog - '${npm_package_version}" | ||
}, | ||
@@ -22,0 +23,0 @@ "repository": { |
@@ -6,2 +6,3 @@ var fg = require('../index.js') | ||
if (process.argv[2] === 'child') { | ||
setTimeout(function(){}, 1000); | ||
console.log('stdout') | ||
@@ -8,0 +9,0 @@ setTimeout(function () {}, 1000) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
175814
2
12
1
242
+ Addedcross-spawn@^4
+ Addedcross-spawn@4.0.2(transitive)
- Removedcross-spawn-async@^2.1.1
- Removedwhich@^1.2.1
- Removedcross-spawn-async@2.2.5(transitive)