Skip to content

Commit

Permalink
Reuse extensions definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
ventuno committed Apr 24, 2022
1 parent 8328705 commit 17e1946
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/extract-templates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseTemplates } from 'ember-template-imports/lib/parse-templates.js';

const extensions = ['js', 'ts', 'gjs', 'gts'];
export const SUPPORTED_EXTENSIONS = ['js', 'ts', 'gjs', 'gts'];
const LOCATION_START = Object.freeze({ line: 0, column: 0 });
/**
* @typedef {object} TemplateInfo
Expand All @@ -17,7 +17,7 @@ const LOCATION_START = Object.freeze({ line: 0, column: 0 });
export function extractTemplates(moduleSource, relativePath) {
// If no relativePath is present, assuming we might have templates.
let mightHaveTemplates = relativePath
? extensions.some((ext) => relativePath.endsWith(ext))
? SUPPORTED_EXTENSIONS.some((ext) => relativePath.endsWith(ext))
: true;

if (!mightHaveTemplates) {
Expand Down
3 changes: 2 additions & 1 deletion lib/helpers/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import path from 'node:path';
import yargs from 'yargs';

import camelize from './camelize.js';
import { SUPPORTED_EXTENSIONS } from '../extract-templates.js';

const STDIN = '/dev/stdin';

Expand Down Expand Up @@ -228,7 +229,7 @@ export function getPossibleOptionNames(specifiedOptions) {
}

function executeGlobby(workingDir, pattern, ignore) {
let supportedExtensions = new Set(['.hbs', '.handlebars', '.js', '.ts', '.gjs', '.gts']);
let supportedExtensions = new Set(['.hbs', '.handlebars', ...SUPPORTED_EXTENSIONS]);

// `--no-ignore-pattern` results in `ignorePattern === [false]`
let options =
Expand Down

0 comments on commit 17e1946

Please sign in to comment.