File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,43 @@ var Host = (function () {
77
77
Host . prototype . getDefaultLibFileName = function ( ) {
78
78
return '__lib.d.ts' ;
79
79
} ;
80
+ Host . prototype . fileExists = function ( fileName ) {
81
+ if ( fileName === '__lib.d.ts' ) {
82
+ return true ;
83
+ }
84
+ var sourceFile = this . input . getFile ( fileName ) ;
85
+ if ( sourceFile )
86
+ return true ;
87
+ if ( this . externalResolve ) {
88
+ try {
89
+ var stat = fs . statSync ( fileName ) ;
90
+ if ( ! stat )
91
+ return false ;
92
+ return stat . isFile ( ) ;
93
+ }
94
+ catch ( ex ) {
95
+ }
96
+ }
97
+ return false ;
98
+ } ;
99
+ Host . prototype . readFile = function ( fileName ) {
100
+ var normalizedFileName = utils . normalizePath ( fileName ) ;
101
+ var sourceFile = this . input . getFile ( fileName ) ;
102
+ if ( sourceFile )
103
+ return sourceFile . content ;
104
+ if ( this . externalResolve ) {
105
+ // Read the whole file (and cache contents) to prevent race conditions.
106
+ var text ;
107
+ try {
108
+ text = fs . readFileSync ( fileName ) . toString ( 'utf8' ) ;
109
+ }
110
+ catch ( ex ) {
111
+ return undefined ;
112
+ }
113
+ return text ;
114
+ }
115
+ return undefined ;
116
+ } ;
80
117
Host . libDefault = { } ;
81
118
return Host ;
82
119
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments