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

Commit 1c7eae0

Browse files
committed
Updating the binary script to understand debug, so that
protractor debug conf.js works.
1 parent 2fddb29 commit 1c7eae0

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

bin/protractor

+38-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,41 @@
22

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

5-
var path = require('path');
6-
require(path.join(__dirname,'../lib/cli.js'));
5+
/**
6+
* This tiny wrapper file checks for node debug flags and appends them
7+
* when found, before invoking the real executable. Thanks to mocha for the
8+
* pattern.
9+
*/
10+
11+
var spawn = require('child_process').spawn,
12+
args = [__dirname + '/../lib/cli.js'];
13+
14+
process.argv.slice(2).forEach(function(arg) {
15+
var flag = arg.split('=')[0];
16+
17+
switch (flag) {
18+
case '-d':
19+
args.unshift('--debug');
20+
break;
21+
case 'debug':
22+
case '--debug':
23+
case '--debug-brk':
24+
args.unshift(arg);
25+
break;
26+
default:
27+
if (0 == arg.indexOf('--trace')) args.unshift(arg);
28+
else args.push(arg);
29+
break;
30+
}
31+
});
32+
33+
var proc = spawn(process.argv[0], args, { stdio: 'inherit' });
34+
proc.on('exit', function (code, signal) {
35+
process.on('exit', function() {
36+
if (signal) {
37+
process.kill(process.pid, signal);
38+
} else {
39+
process.exit(code);
40+
}
41+
});
42+
});

0 commit comments

Comments
 (0)