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

Update compat to check for both *.hbs & *.hbs.js #1294

Merged
merged 1 commit into from Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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