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

fix: space in shebang path for windows #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
- nodejs_version: '4'
install:
- ps: Install-Product node $env:nodejs_version
- npm -g install npm@latest
- npm -g install npm@lts
- set PATH=%APPDATA%\npm;%PATH%
- npm install
matrix:
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ var debug = doDebug ? function () {
process.stderr.write(message + '\n')
} : function () {}

var shebang = process.platform === 'os390' ?
var isWindows = require('./lib/is-windows')()

var shebang = isWindows || process.platform === 'os390' ?
'#!/bin/env ' : '#!'

var shim = shebang + process.execPath + '\n' +
fs.readFileSync(__dirname + '/shim.js')

var isWindows = require('./lib/is-windows')()

var pathRe = /^PATH=/
if (isWindows) pathRe = /^PATH=/i

Expand Down
16 changes: 15 additions & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (process.argv[2] === 'parent') {
console.log('EXIT %j', [code, signal])
})
var argv = process.argv.slice(3).map(function (arg) {
if (arg === fixture) {
if (path.resolve(arg) === fixture) {
return '{{FIXTURE}}'
}
return arg
Expand Down Expand Up @@ -271,6 +271,20 @@ t.test('exec execPath', function (t) {
})
})

t.test('windows shebang', function (t) {
var child = cp.spawn('env', [fixture, 'xyz'])
var out = ''
child.stdout.on('data', function (c) {
out += c
})
child.on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.equal(out, expect)
t.end()
})
})

t.test('exec shebang', { skip: winNoShebang }, function (t) {
t.plan(3)

Expand Down