1+ /// <reference path="..\src\harness\external\node.d.ts" />
2+
3+ import cp = require( 'child_process' ) ;
4+ import fs = require( 'fs' ) ;
5+
6+ var args = process . argv . slice ( 2 ) ;
7+
8+ var jake = cp . exec ( 'jake clean local' , ( ) => void 0 ) ;
9+ jake . on ( 'close' , code => {
10+ if ( code === 0 ) {
11+ // See what we're being asked to do
12+ 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' ) ) {
16+ console . log ( 'Good' ) ;
17+ process . exit ( 0 ) ; // Good
18+ } else {
19+ console . log ( 'Bad' ) ;
20+ process . exit ( 1 ) ; // Bad
21+ }
22+ } ) ;
23+ } 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 => {
26+ fs . readFile ( args [ 2 ] , 'utf-8' , ( err , data ) => {
27+ var doesContains = data . indexOf ( args [ 3 ] ) >= 0 ;
28+ if ( doesContains === ( args [ 1 ] === 'emits' ) ) {
29+ console . log ( 'Good' ) ;
30+ process . exit ( 0 ) ; // Good
31+ } else {
32+ console . log ( 'Bad' ) ;
33+ process . exit ( 1 ) ; // Bad
34+ }
35+ } ) ;
36+ } ) ;
37+ } else {
38+ console . log ( 'Unknown command line arguments.' ) ;
39+ console . log ( 'Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles' ) ;
40+ console . log ( 'Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"' ) ;
41+ process . exit ( - 1 ) ;
42+ }
43+ } else {
44+ // Build failed
45+ process . exit ( 125 ) ; // bisect skip
46+ }
47+ } ) ;
48+
0 commit comments