Skip to content

Commit c83c1b1

Browse files
committed
only update files if they exist in the input tree
1 parent a59da21 commit c83c1b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/compat/src/compat-adapters/ember-source.ts

+8
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ function updateFileWithTransform(
404404
file: string,
405405
transformFunction: Babel.PluginItem | Babel.PluginItem[]
406406
) {
407+
// only update the file if it exists - this helps the codemods to work across many different versions
408+
if (!existsSync(resolve(context.inputPaths[0], file))) {
409+
return;
410+
}
407411
let inSource = readFileSync(resolve(context.inputPaths[0], file), 'utf8');
408412

409413
let plugins = Array.isArray(transformFunction) ? transformFunction : [transformFunction];
@@ -415,6 +419,10 @@ function updateFileWithTransform(
415419
}
416420

417421
function replaceFile(context: Plugin, file: string, content: string) {
422+
// only update the file if it exists - this helps the codemods to work across many different versions
423+
if (!existsSync(resolve(context.inputPaths[0], file))) {
424+
return;
425+
}
418426
outputFileSync(resolve(context.outputPath, file), content, 'utf8');
419427
}
420428

0 commit comments

Comments
 (0)