Skip to content

Commit e1733ef

Browse files
committed
Update LKG
1 parent 71bc975 commit e1733ef

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

release/host.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,43 @@ var Host = (function () {
7777
Host.prototype.getDefaultLibFileName = function () {
7878
return '__lib.d.ts';
7979
};
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+
};
80117
Host.libDefault = {};
81118
return Host;
82119
})();

0 commit comments

Comments
 (0)