Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transpile crash when file was changed in beforeTranspile events #627

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1345,8 +1345,10 @@ export class Program {

const processedFiles = new Set<File>();

const transpileFile = async (file: BscFile, outputPath?: string) => {
//mark this file as processed so we don't do it again
const transpileFile = async (srcPath: string, outputPath?: string) => {
//find the file in the program
const file = this.getFile(srcPath);
//mark this file as processed so we don't process it more than once
processedFiles.add(file);

//skip transpiling typedef files
Expand Down Expand Up @@ -1386,7 +1388,7 @@ export class Program {
this.plugins.emit('beforeProgramTranspile', this, entries, astEditor);

let promises = entries.map(async (entry) => {
return transpileFile(entry.file, entry.outputPath);
return transpileFile(entry?.file?.srcPath, entry.outputPath);
});

//if there's no bslib file already loaded into the program, copy it to the staging directory
Expand All @@ -1403,7 +1405,7 @@ export class Program {
//this is a new file
if (!processedFiles.has(file)) {
promises.push(
transpileFile(file, getOutputPath(file))
transpileFile(file?.srcPath, getOutputPath(file))
);
}
}
Expand Down