-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
a couple tweaks to make things work on windows #5
Changes from 8 commits
9f02626
8475c8a
2716443
20a4957
1c87b8c
cb1fada
f2d8197
47cfd55
fd338fe
d7abc06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function () { | ||
return process.platform === 'win32' || | ||
process.env.OSTYPE === 'cygwin' || | ||
process.env.OSTYPE === 'msys' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var re = new RegExp(/(.*((node\.exe($| ))|(node($| ))|(iojs($| ))|(iojs\.exe($| )))) ?(.*)$/) | ||
|
||
module.exports = function (path, rebase) { | ||
var m = path.match(re) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I generally would use I'm curious, is there a specific reason for this form? Or is it just what happened to flow from your fingers while typing it up? No wrong answer, I'm honestly curious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rmg this is just what fell out of my fingers, no good reason -- I find I flip flop a lot on how I build up regexes. |
||
if (!m) return path | ||
return path.replace(m[1].trim(), rebase) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var sw = require('../') | ||
var onExit = require('signal-exit') | ||
|
||
var cp = require('child_process') | ||
var spawn = require('child_process').spawn | ||
var fixture = require.resolve('./fixtures/script.js') | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
@@ -38,7 +38,7 @@ var expect = 'WRAP ["{{FIXTURE}}","xyz"]\n' + | |
'EXIT [0,null]\n' | ||
|
||
t.test('spawn execPath', function (t) { | ||
var child = cp.spawn(process.execPath, [fixture, 'xyz']) | ||
var child = spawn(process.execPath, [fixture, 'xyz']) | ||
|
||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
|
@@ -53,7 +53,7 @@ t.test('spawn execPath', function (t) { | |
}) | ||
|
||
t.test('exec shebang', function (t) { | ||
var child = cp.exec(fixture + ' xyz') | ||
var child = spawn(fixture, ['xyz']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be cp.exec. The failures on Linux can probably be fixed with this diff: diff --git a/test/fixtures/script.js b/test/fixtures/script.js
index 51f518a..ebc08f9 100755
--- a/test/fixtures/script.js
+++ b/test/fixtures/script.js
@@ -1,3 +1,5 @@
#!/usr/bin/env node
console.log('%j', process.execArgv)
console.log('%j', process.argv.slice(2))
+// keep the process open long enough to catch a signal
+setTimeout(function() {}, 500) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's not it. Definitely something weird happening with signal-exit, it's sending the signal, but the exit happens with status 0, not the signal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, apparently signal-exit just straight up does not work on Linux. This is strange. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See tapjs/signal-exit#15. It works fine, but exec() uses a real |
||
|
||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
|
@@ -68,7 +68,7 @@ t.test('exec shebang', function (t) { | |
}) | ||
|
||
t.test('SIGHUP', function (t) { | ||
var child = cp.exec(fixture + ' xyz') | ||
var child = spawn(fixture, ['xyz']) | ||
|
||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
|
@@ -88,7 +88,7 @@ t.test('SIGHUP', function (t) { | |
}) | ||
|
||
t.test('SIGINT', function (t) { | ||
var child = cp.exec(fixture + ' xyz') | ||
var child = spawn(fixture, ['xyz']) | ||
|
||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
|
@@ -114,7 +114,7 @@ t.test('SIGINT', function (t) { | |
|
||
t.test('--harmony', function (t) { | ||
var node = process.execPath | ||
var child = cp.spawn(node, ['--harmony', fixture, 'xyz']) | ||
var child = spawn(node, ['--harmony', fixture, 'xyz']) | ||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
out += c | ||
|
@@ -135,7 +135,7 @@ t.test('node exe with different name', function(t) { | |
var data = fs.readFileSync(process.execPath) | ||
fs.writeFileSync(fp, data) | ||
fs.chmodSync(fp, '0775') | ||
var child = cp.spawn(process.execPath, [fixture, 'xyz']) | ||
var child = spawn(process.execPath, [fixture, 'xyz']) | ||
|
||
var out = '' | ||
child.stdout.on('data', function (c) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var t = require('tap') | ||
var winRebase = require('../lib/win-rebase') | ||
|
||
t.test('it replaces path to node bin', function (t) { | ||
var result = winRebase('C:\\Program Files\\nodejs\\node.exe', 'C:\\foo') | ||
t.equal(result, 'C:\\foo') | ||
t.done() | ||
}) | ||
|
||
t.test('it does not replace path if it references an unknown bin', function (t) { | ||
var result = winRebase('C:\\Program Files\\nodejs\\banana', 'C:\\foo') | ||
t.equal(result, 'C:\\Program Files\\nodejs\\banana') | ||
t.done() | ||
}) | ||
|
||
t.test('replaces node bin and leaves the script being executed', function (t) { | ||
var result = winRebase('C:\\Program Files\\nodejs\\node.exe foo.js', 'C:\\foo') | ||
t.equal(result, 'C:\\foo foo.js') | ||
t.done() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does cygwin actually change
process.platform
to not be'win32'
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rmg I believe I cargo culted this from somwhere, it might have been that I pulled the logic originally sitting in
index.js
tois-windows.js
-- my guess would be there's a good reason for thecygwin
check, it could also be that someone accidentally created a cult and I've been indoctrinated into it.