1
1
/// <reference path="..\src\compiler\sys.ts"/>
2
2
/// <reference path="..\src\compiler\types.ts"/>
3
3
4
- module perftest {
5
-
4
+ namespace perftest {
6
5
interface IOLog {
7
6
resolvePath : ts . Map < string > ;
8
7
fileNames : string [ ] ;
@@ -12,20 +11,20 @@ module perftest {
12
11
getOut ( ) : string ;
13
12
}
14
13
15
- export var readFile = ts . sys . readFile ;
16
- var writeFile = ts . sys . writeFile ;
17
- export var write = ts . sys . write ;
18
- var resolvePath = ts . sys . resolvePath ;
19
- export var getExecutingFilePath = ts . sys . getExecutingFilePath ;
20
- export var getCurrentDirectory = ts . sys . getCurrentDirectory ;
21
- var exit = ts . sys . exit ;
14
+ export const readFile = ts . sys . readFile ;
15
+ const writeFile = ts . sys . writeFile ;
16
+ export const write = ts . sys . write ;
17
+ const resolvePath = ts . sys . resolvePath ;
18
+ export const getExecutingFilePath = ts . sys . getExecutingFilePath ;
19
+ export const getCurrentDirectory = ts . sys . getCurrentDirectory ;
20
+ // const exit = ts.sys.exit;
22
21
23
- var args = ts . sys . args ;
22
+ const args = ts . sys . args ;
24
23
25
24
// augment sys so first ts.executeCommandLine call will be finish silently
26
25
ts . sys . write = ( s : string ) => { } ;
27
26
ts . sys . exit = ( code : number ) => { } ;
28
- ts . sys . args = [ ]
27
+ ts . sys . args = [ ] ;
29
28
30
29
export function restoreSys ( ) {
31
30
ts . sys . args = args ;
@@ -44,19 +43,19 @@ module perftest {
44
43
return args . slice ( 1 ) ;
45
44
}
46
45
47
- var resolvePathLog : ts . Map < string > = { } ;
48
-
46
+ const resolvePathLog : ts . Map < string > = { } ;
47
+
49
48
export function interceptIO ( ) {
50
49
ts . sys . resolvePath = ( s ) => {
51
- var result = resolvePath ( s ) ;
50
+ const result = resolvePath ( s ) ;
52
51
resolvePathLog [ s ] = result ;
53
52
return result ;
54
53
} ;
55
54
}
56
55
57
56
export function writeIOLog ( fileNames : string [ ] ) {
58
- var path = args [ 1 ] ;
59
- var log : IOLog = {
57
+ const path = args [ 1 ] ;
58
+ const log : IOLog = {
60
59
fileNames : fileNames ,
61
60
resolvePath : resolvePathLog
62
61
} ;
@@ -65,36 +64,36 @@ module perftest {
65
64
}
66
65
67
66
export function prepare ( ) : IO {
68
- var log = < IOLog > JSON . parse ( readFile ( args [ 0 ] ) ) ;
67
+ const log = < IOLog > JSON . parse ( readFile ( args [ 0 ] ) ) ;
68
+
69
+ const files : ts . Map < string > = { } ;
70
+ log . fileNames . forEach ( f => { files [ f ] = readFile ( f ) ; } ) ;
69
71
70
- var files : ts . Map < string > = { } ;
71
- log . fileNames . forEach ( f => { files [ f ] = readFile ( f ) ; } )
72
-
73
72
ts . sys . createDirectory = ( s : string ) => { } ;
74
73
ts . sys . directoryExists = ( s : string ) => true ;
75
74
ts . sys . fileExists = ( s : string ) => true ;
76
75
77
- var currentDirectory = ts . sys . getCurrentDirectory ( ) ;
76
+ const currentDirectory = ts . sys . getCurrentDirectory ( ) ;
78
77
ts . sys . getCurrentDirectory = ( ) => currentDirectory ;
79
78
80
- var executingFilePath = ts . sys . getExecutingFilePath ( ) ;
79
+ const executingFilePath = ts . sys . getExecutingFilePath ( ) ;
81
80
ts . sys . getExecutingFilePath = ( ) => executingFilePath ;
82
81
83
82
ts . sys . readFile = ( s : string ) => {
84
83
return files [ s ] ;
85
- }
84
+ } ;
86
85
87
86
ts . sys . resolvePath = ( s : string ) => {
88
- var path = log . resolvePath [ s ] ;
87
+ const path = log . resolvePath [ s ] ;
89
88
if ( ! path ) {
90
89
throw new Error ( "Unexpected path '" + s + "'" ) ;
91
90
}
92
- return path
93
- }
91
+ return path ;
92
+ } ;
94
93
95
94
ts . sys . writeFile = ( path : string , data : string ) => { } ;
96
95
97
- var out : string = "" ;
96
+ let out = "" ;
98
97
99
98
ts . sys . write = ( s : string ) => { out += s ; } ;
100
99
0 commit comments