mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Instead of checking if file exists before file read, handle exceptions from file read (#36244)
Fixes #36236
This commit is contained in:
+5
-2
@@ -1559,10 +1559,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function readFileWorker(fileName: string, _encoding?: string): string | undefined {
|
||||
if (!fileExists(fileName)) {
|
||||
let buffer: Buffer;
|
||||
try {
|
||||
buffer = _fs.readFileSync(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
const buffer = _fs.readFileSync(fileName);
|
||||
let len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
|
||||
Reference in New Issue
Block a user