Skip to content

Commit 779ce3b

Browse files
author
Robert Jackson
authored
Do nothing for non-JS files. (#150)
Do nothing for non-JS files.
2 parents 1d07b9b + a9a8031 commit 779ce3b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

transforms/ember-object/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const path = require('path');
12
const { getOptions } = require('codemod-cli');
23
const { replaceEmberObjectExpressions } = require('../helpers/parse-helper');
34

@@ -9,13 +10,20 @@ const DEFAULT_OPTIONS = {
910
};
1011

1112
module.exports = function transformer(file, api) {
13+
const extension = path.extname(file.path);
14+
15+
if (!['.js', '.ts'].includes(extension.toLowerCase())) {
16+
// do nothing on non-js/ts files
17+
return;
18+
}
19+
1220
const j = api.jscodeshift;
1321
const options = Object.assign({}, DEFAULT_OPTIONS, getOptions());
14-
let { source, path } = file;
22+
let { source } = file;
1523

1624
const root = j(source);
1725

18-
const replaced = replaceEmberObjectExpressions(j, root, path, options);
26+
const replaced = replaceEmberObjectExpressions(j, root, file.path, options);
1927
if (replaced) {
2028
source = root.toSource({
2129
quote: options.quotes || options.quote,

0 commit comments

Comments
 (0)