From b44a93be28ad9cf1664ddde68a23443791819dad Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Mon, 13 Jun 2022 11:07:12 -0400 Subject: [PATCH] Fix transpile crash when file was changed in beforeTranspile events --- src/Program.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Program.ts b/src/Program.ts index 24e60d8bf..5037d5e55 100644 --- a/src/Program.ts +++ b/src/Program.ts @@ -1345,8 +1345,10 @@ export class Program { const processedFiles = new Set(); - 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 @@ -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 @@ -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)) ); } }