File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const path = require ( 'path' ) ;
12const { getOptions } = require ( 'codemod-cli' ) ;
23const { replaceEmberObjectExpressions } = require ( '../helpers/parse-helper' ) ;
34
@@ -9,13 +10,20 @@ const DEFAULT_OPTIONS = {
910} ;
1011
1112module . 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 ,
You can’t perform that action at this time.
0 commit comments