Skip to content

Commit

Permalink
Update compat to check for both *.hbs & *.hbs.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Nov 26, 2022
1 parent e0bd093 commit 82d353a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -65,3 +65,7 @@ tmp/

# scenario tester debugging output
tests/scenarios/output/

# Sys files
.DS_Store
*.swp
16 changes: 9 additions & 7 deletions packages/compat/src/synthesize-template-only-components.ts
Expand Up @@ -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'];

Expand Down Expand Up @@ -60,12 +60,14 @@ function crawl(dir: string) {
const seen = new Set<string>();
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));
}
}
}
}
Expand Down

0 comments on commit 82d353a

Please sign in to comment.