33import cp = require( 'child_process' ) ;
44import fs = require( 'fs' ) ;
55
6+ // Slice off 'node bisect-test.js' from the commandline args
67var args = process . argv . slice ( 2 ) ;
78
9+ function tsc ( tscArgs : string , onExit : ( exitCode : number ) => void ) {
10+ var tsc = cp . exec ( 'node built/local/tsc.js ' + tscArgs , ( ) => void 0 ) ;
11+ tsc . on ( 'close' , tscExitCode => {
12+ onExit ( tscExitCode ) ;
13+ } ) ;
14+ }
15+
816var jake = cp . exec ( 'jake clean local' , ( ) => void 0 ) ;
9- jake . on ( 'close' , code => {
10- if ( code === 0 ) {
17+ jake . on ( 'close' , jakeExitCode => {
18+ if ( jakeExitCode === 0 ) {
1119 // See what we're being asked to do
1220 if ( args [ 1 ] === 'compiles' || args [ 1 ] === '!compiles' ) {
13- var tsc = cp . exec ( 'node built/local/tsc.js ' + args [ 0 ] , ( ) => void 0 ) ;
14- tsc . on ( 'close' , tscCode => {
15- if ( ( tscCode === 0 ) === ( args [ 1 ] === 'compiles' ) ) {
21+ tsc ( args [ 0 ] , tscExitCode => {
22+ if ( ( tscExitCode === 0 ) === ( args [ 1 ] === 'compiles' ) ) {
1623 console . log ( 'Good' ) ;
1724 process . exit ( 0 ) ; // Good
1825 } else {
@@ -21,8 +28,7 @@ jake.on('close', code => {
2128 }
2229 } ) ;
2330 } else if ( args [ 1 ] === 'emits' || args [ 1 ] === '!emits' ) {
24- var tsc = cp . exec ( 'node built/local/tsc.js ' + args [ 0 ] , ( ) => void 0 ) ;
25- tsc . on ( 'close' , tscCode => {
31+ tsc ( args [ 0 ] , tscExitCode => {
2632 fs . readFile ( args [ 2 ] , 'utf-8' , ( err , data ) => {
2733 var doesContains = data . indexOf ( args [ 3 ] ) >= 0 ;
2834 if ( doesContains === ( args [ 1 ] === 'emits' ) ) {
@@ -38,10 +44,12 @@ jake.on('close', code => {
3844 console . log ( 'Unknown command line arguments.' ) ;
3945 console . log ( 'Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles' ) ;
4046 console . log ( 'Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"' ) ;
47+ // Aborts the 'git bisect run' process
4148 process . exit ( - 1 ) ;
4249 }
4350 } else {
44- // Build failed
51+ // Compiler build failed; skip this commit
52+ console . log ( 'Skip' ) ;
4553 process . exit ( 125 ) ; // bisect skip
4654 }
4755} ) ;
0 commit comments