Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip .exe suffix via case-insensitive replacement (fixes #55 and #56) #57

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ function isNode (file) {

function mungeNode (workingDir, options) {
options.originalNode = options.file
var command = path.basename(options.file, '.exe')
// Strip a '.exe' extension via a case-insensitive replacement
// rather than via the case-sensitive 'ext` parameter to path.basename
// because it might be capitalized ('.EXE').
var command = path.basename(options.file).replace(/\.exe$/i, '')
// make sure it has a main script.
// otherwise, just let it through.
var a = 0
Expand Down
5 changes: 3 additions & 2 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ t.test('exec execPath', function (t) {

t.test('basic', function (t) {
var opt = isWindows ? null : { shell: '/bin/bash' }
var child = cp.exec(process.execPath + ' ' + fixture + ' xyz', opt)

// Enclose process.execPath in quotes in case it contains spaces
// (especially on Windows, where it might contain "Program Files").
var child = cp.exec('"' + process.execPath + '"' + ' ' + fixture + ' xyz', opt)
var out = ''
child.stdout.on('data', function (c) {
out += c
Expand Down
9 changes: 7 additions & 2 deletions test/exec-flag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var sw = require('../')
var isWindows = require('../lib/is-windows.js')()

if (process.argv[2] === 'wrapper') {
// note: this should never happen,
Expand Down Expand Up @@ -34,10 +35,14 @@ t.test('wrap a -e invocation', function (t) {
code: code,
signal: signal
}
// Per <https://nodejs.org/api/process.html>, "Sending SIGINT,
// SIGTERM, and SIGKILL cause the unconditional termination
// of the target process." So Node ignores our SIGTERM handler,
// and the process ends when killed with that signal.
var expect = {
out: /^(wtf\n)*ignore!\n(wtf\n)*$/,
out: isWindows ? /^(wtf\n)*$/ : /^(wtf\n)*ignore!\n(wtf\n)*$/,
code: null,
signal: 'SIGKILL'
signal: isWindows ? 'SIGTERM' : 'SIGKILL'
}
t.match(actual, expect)
t.end()
Expand Down