22
22
/// <reference path='external\chai.d.ts'/>
23
23
/// <reference path='sourceMapRecorder.ts'/>
24
24
25
+ declare var require : any ;
26
+ declare var process : any ;
27
+
25
28
// this will work in the browser via browserify
26
29
var _chai : typeof chai = require ( 'chai' ) ;
27
30
var assert : typeof _chai . assert = _chai . assert ;
@@ -41,7 +44,7 @@ module Utils {
41
44
export function getExecutionEnvironment ( ) {
42
45
if ( typeof WScript !== "undefined" && typeof ActiveXObject === "function" ) {
43
46
return ExecutionEnvironment . CScript ;
44
- } else if ( process && ( < any > process ) . execPath && ( < any > process ) . execPath . indexOf ( "node" ) !== - 1 ) {
47
+ } else if ( process && process . execPath && process . execPath . indexOf ( "node" ) !== - 1 ) {
45
48
return ExecutionEnvironment . Node ;
46
49
} else {
47
50
return ExecutionEnvironment . Browser ;
@@ -89,7 +92,7 @@ module Utils {
89
92
}
90
93
91
94
try {
92
- var content = sys . readFile ( Harness . userSpecifiedroot + path ) ;
95
+ var content = ts . sys . readFile ( Harness . userSpecifiedroot + path ) ;
93
96
}
94
97
catch ( err ) {
95
98
return undefined ;
@@ -156,8 +159,8 @@ module Harness {
156
159
fso = { } ;
157
160
}
158
161
159
- export var readFile : typeof IO . readFile = sys . readFile ;
160
- export var writeFile : typeof IO . writeFile = sys . writeFile ;
162
+ export var readFile : typeof IO . readFile = ts . sys . readFile ;
163
+ export var writeFile : typeof IO . writeFile = ts . sys . writeFile ;
161
164
export var directoryName : typeof IO . directoryName = fso . GetParentFolderName ;
162
165
export var directoryExists : typeof IO . directoryExists = fso . FolderExists ;
163
166
export var fileExists : typeof IO . fileExists = fso . FileExists ;
@@ -218,8 +221,8 @@ module Harness {
218
221
fs = pathModule = { } ;
219
222
}
220
223
221
- export var readFile : typeof IO . readFile = sys . readFile ;
222
- export var writeFile : typeof IO . writeFile = sys . writeFile ;
224
+ export var readFile : typeof IO . readFile = ts . sys . readFile ;
225
+ export var writeFile : typeof IO . writeFile = ts . sys . writeFile ;
223
226
export var fileExists : typeof IO . fileExists = fs . existsSync ;
224
227
export var log : typeof IO . log = console . log ;
225
228
@@ -547,7 +550,7 @@ module Harness {
547
550
export var fourslashSourceFile : ts . SourceFile ;
548
551
549
552
export function getCanonicalFileName ( fileName : string ) : string {
550
- return sys . useCaseSensitiveFileNames ? fileName : fileName . toLowerCase ( ) ;
553
+ return ts . sys . useCaseSensitiveFileNames ? fileName : fileName . toLowerCase ( ) ;
551
554
}
552
555
553
556
export function createCompilerHost ( inputFiles : { unitName : string ; content : string ; } [ ] ,
@@ -571,7 +574,7 @@ module Harness {
571
574
inputFiles . forEach ( register ) ;
572
575
573
576
return {
574
- getCurrentDirectory : sys . getCurrentDirectory ,
577
+ getCurrentDirectory : ts . sys . getCurrentDirectory ,
575
578
getCancellationToken : ( ) : any => undefined ,
576
579
getSourceFile : ( fn , languageVersion ) => {
577
580
if ( Object . prototype . hasOwnProperty . call ( filemap , getCanonicalFileName ( fn ) ) ) {
@@ -594,7 +597,7 @@ module Harness {
594
597
writeFile,
595
598
getCanonicalFileName,
596
599
useCaseSensitiveFileNames : ( ) => useCaseSensitiveFileNames ,
597
- getNewLine : ( ) => sys . newLine
600
+ getNewLine : ( ) => ts . sys . newLine
598
601
} ;
599
602
}
600
603
@@ -664,7 +667,7 @@ module Harness {
664
667
settingsCallback ( null ) ;
665
668
}
666
669
667
- var useCaseSensitiveFileNames = sys . useCaseSensitiveFileNames ;
670
+ var useCaseSensitiveFileNames = ts . sys . useCaseSensitiveFileNames ;
668
671
this . settings . forEach ( setting => {
669
672
switch ( setting . flag . toLowerCase ( ) ) {
670
673
// "filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
@@ -742,7 +745,7 @@ module Harness {
742
745
743
746
case 'newline' :
744
747
case 'newlines' :
745
- sys . newLine = setting . value ;
748
+ ts . sys . newLine = setting . value ;
746
749
break ;
747
750
748
751
case 'comments' :
@@ -817,11 +820,11 @@ module Harness {
817
820
} ) ;
818
821
this . lastErrors = errors ;
819
822
820
- var result = new CompilerResult ( fileOutputs , errors , program , sys . getCurrentDirectory ( ) , emitResult ? emitResult . sourceMaps : undefined ) ;
823
+ var result = new CompilerResult ( fileOutputs , errors , program , ts . sys . getCurrentDirectory ( ) , emitResult ? emitResult . sourceMaps : undefined ) ;
821
824
onComplete ( result , checker ) ;
822
825
823
826
// reset what newline means in case the last test changed it
824
- sys . newLine = '\r\n' ;
827
+ ts . sys . newLine = '\r\n' ;
825
828
return options ;
826
829
}
827
830
@@ -916,7 +919,7 @@ module Harness {
916
919
errorOutput += diagnotic . filename + "(" + diagnotic . line + "," + diagnotic . character + "): " ;
917
920
}
918
921
919
- errorOutput += diagnotic . category + " TS" + diagnotic . code + ": " + diagnotic . message + sys . newLine ;
922
+ errorOutput += diagnotic . category + " TS" + diagnotic . code + ": " + diagnotic . message + ts . sys . newLine ;
920
923
} ) ;
921
924
922
925
return errorOutput ;
@@ -1014,7 +1017,7 @@ module Harness {
1014
1017
assert . equal ( totalErrorsReported + numLibraryDiagnostics , diagnostics . length , 'total number of errors' ) ;
1015
1018
1016
1019
return minimalDiagnosticsToString ( diagnostics ) +
1017
- sys . newLine + sys . newLine + outputLines . join ( '\r\n' ) ;
1020
+ ts . sys . newLine + ts . sys . newLine + outputLines . join ( '\r\n' ) ;
1018
1021
}
1019
1022
1020
1023
export function collateOutputs ( outputFiles : Harness . Compiler . GeneratedFile [ ] , clean ?: ( s : string ) => string ) {
0 commit comments