Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Updating the binary script to understand debug, so that
Browse files Browse the repository at this point in the history
protractor debug conf.js works.
  • Loading branch information
juliemr committed Aug 23, 2013
1 parent 2fddb29 commit 1c7eae0
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions bin/protractor
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,41 @@

if( !process.env.NODE_ENV ) process.env.NODE_ENV = 'test';

var path = require('path');
require(path.join(__dirname,'../lib/cli.js'));
/**
* This tiny wrapper file checks for node debug flags and appends them
* when found, before invoking the real executable. Thanks to mocha for the
* pattern.
*/

var spawn = require('child_process').spawn,
args = [__dirname + '/../lib/cli.js'];

process.argv.slice(2).forEach(function(arg) {
var flag = arg.split('=')[0];

switch (flag) {
case '-d':
args.unshift('--debug');
break;
case 'debug':
case '--debug':
case '--debug-brk':
args.unshift(arg);
break;
default:
if (0 == arg.indexOf('--trace')) args.unshift(arg);
else args.push(arg);
break;
}
});

var proc = spawn(process.argv[0], args, { stdio: 'inherit' });
proc.on('exit', function (code, signal) {
process.on('exit', function() {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
});
});

0 comments on commit 1c7eae0

Please sign in to comment.