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(task): prevent spawn ENAMETOOLONG on Windows #163

Merged
merged 1 commit into from
Sep 9, 2015
Merged
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
9 changes: 5 additions & 4 deletions lib/background.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var Server = require('karma').Server
var data = JSON.parse(process.argv[2])
var server = new Server(data)

server.start(data)
process.stdin.on('readable', function () {
var data = JSON.parse(process.stdin.read())
var server = new Server(data)
server.start(data)
})
18 changes: 10 additions & 8 deletions tasks/grunt-karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ module.exports = function (grunt) {

// allow karma to be run in the background so it doesn't block grunt
if (data.background) {
var backgroundArgs = {
cmd: 'node',
args: process.execArgv.concat([

var backgroundProcess = require('child_process').fork(
path.join(__dirname, '..', 'lib', 'background.js'),
JSON.stringify(data)
])
}
var backgroundProcess = grunt.util.spawn(backgroundArgs, function (error) {
{ silent: true }
)
backgroundProcess.stdin.write(JSON.stringify(data))

backgroundProcess.on('close', function (code) {
var error = code
if (error) {
grunt.log.error(error)
grunt.log.error('background karma process exited with error (code: ' + code + ')')
}
})

process.on('exit', function () {
backgroundProcess.kill()
})
Expand Down