From 82d353a8310938daaa9b7c934dd72d853968c756 Mon Sep 17 00:00:00 2001 From: kiosion Date: Sat, 26 Nov 2022 16:53:20 -0400 Subject: [PATCH] Update compat to check for both `*.hbs` & `*.hbs.js` --- .gitignore | 4 ++++ .../src/synthesize-template-only-components.ts | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5ebab51a2..34ba5d5a9 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,7 @@ tmp/ # scenario tester debugging output tests/scenarios/output/ + +# Sys files +.DS_Store +*.swp diff --git a/packages/compat/src/synthesize-template-only-components.ts b/packages/compat/src/synthesize-template-only-components.ts index bfd0ed868..a56a6efad 100644 --- a/packages/compat/src/synthesize-template-only-components.ts +++ b/packages/compat/src/synthesize-template-only-components.ts @@ -7,7 +7,7 @@ import { remove, outputFileSync, pathExistsSync } from 'fs-extra'; const source = `import templateOnlyComponent from '@ember/component/template-only'; export default templateOnlyComponent();`; -const templateExtension = '.hbs'; +const templateExtensions = ['.hbs', '.hbs.js']; const jsExtensions = ['.js', '.ts', '.mjs', '.mts']; @@ -60,12 +60,14 @@ function crawl(dir: string) { const seen = new Set(); if (pathExistsSync(dir)) { for (let file of walkSync(dir, { directories: false })) { - if (file.endsWith(templateExtension)) { - needed.add(file.slice(0, -1 * templateExtension.length)); - } else { - const jsExtension = jsExtensions.find(ext => file.endsWith(ext)); - if (jsExtension) { - seen.add(file.slice(0, -1 * jsExtension.length)); + for (const templateExtension of templateExtensions) { + if (file.endsWith(templateExtension)) { + needed.add(file.slice(0, -1 * templateExtension.length)); + } else { + const jsExtension = jsExtensions.find(ext => file.endsWith(ext)); + if (jsExtension) { + seen.add(file.slice(0, -1 * jsExtension.length)); + } } } }