Skip to content

Commit

Permalink
fix(ts-morph): surface read file errors instead of ignoring them
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Nov 21, 2021
1 parent 9a04d32 commit 760fe8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
7 changes: 1 addition & 6 deletions deno/ts_morph.js
Original file line number Diff line number Diff line change
Expand Up @@ -19132,12 +19132,7 @@ class CompilerFactory {
filePath = this.context.fileSystemWrapper.getStandardizedAbsolutePath(filePath);
let sourceFile = this.sourceFileCacheByFilePath.get(filePath);
if (sourceFile == null) {
let fileText;
try {
fileText = this.context.fileSystemWrapper.readFileSync(filePath, this.context.getEncoding());
}
catch (_a) {
}
const fileText = this.context.fileSystemWrapper.readFileIfExistsSync(filePath, this.context.getEncoding());
if (fileText != null) {
this.context.logger.log(`Loaded file: ${filePath}`);
sourceFile = this.createSourceFileFromTextInternal(filePath, fileText, options);
Expand Down
8 changes: 1 addition & 7 deletions packages/ts-morph/src/factories/CompilerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ export class CompilerFactory {
filePath = this.context.fileSystemWrapper.getStandardizedAbsolutePath(filePath);
let sourceFile = this.sourceFileCacheByFilePath.get(filePath);
if (sourceFile == null) {
let fileText: string | undefined;
try {
fileText = this.context.fileSystemWrapper.readFileSync(filePath, this.context.getEncoding());
} catch {
// ignore
}

const fileText = this.context.fileSystemWrapper.readFileIfExistsSync(filePath, this.context.getEncoding());
if (fileText != null) {
this.context.logger.log(`Loaded file: ${filePath}`);
sourceFile = this.createSourceFileFromTextInternal(filePath, fileText, options);
Expand Down

0 comments on commit 760fe8c

Please sign in to comment.