Skip to content

Commit b65885f

Browse files
author
Robert Jackson
committed
Refactor extensions into an extra runTransform argument.
1 parent 2ea4a15 commit b65885f

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ to add `--extensions=hbs,jsx`:
6969

7070
require('codemod-cli').runTransform(
7171
__dirname,
72-
process.argv[2] /* transform name */,
73-
process.argv.slice(3) /* paths or globs */
74-
75-
'--extensions=hbs,jsx'
72+
process.argv[2], /* transform name */,
73+
process.argv.slice(3), /* paths or globs */
74+
'hbs,jsx'
7675
)
7776
```
7877

src/bin-support.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const DEFAULT_EXTENSIONS = 'js,ts';
44

5-
async function runTransform(binRoot, transformName, args) {
5+
async function runTransform(binRoot, transformName, args, extensions = DEFAULT_EXTENSIONS) {
66
const globby = require('globby');
77
const execa = require('execa');
88
const chalk = require('chalk');
@@ -19,8 +19,6 @@ async function runTransform(binRoot, transformName, args) {
1919
let jscodeshiftPath = path.dirname(require.resolve('jscodeshift/package'));
2020
let binPath = path.join(jscodeshiftPath, jscodeshiftPkg.bin.jscodeshift);
2121

22-
let extensions = options.extensions || DEFAULT_EXTENSIONS;
23-
2422
let binOptions = ['-t', transformPath, '--extensions', extensions, ...foundPaths];
2523

2624
return execa(binPath, binOptions, {

tests/cli-test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,7 @@ QUnit.module('codemod-cli', function(hooks) {
410410
foo: { 'something.hbs': `<Foo />` },
411411
});
412412

413-
await CodemodCLI.runTransform(codemodProject.path('bin'), 'main', [
414-
'--extensions',
415-
'hbs',
416-
'foo/**',
417-
]);
413+
await CodemodCLI.runTransform(codemodProject.path('bin'), 'main', ['foo/**'], 'hbs');
418414

419415
assert.deepEqual(userProject.read(), {
420416
foo: { 'something.hbs': `<FOO />` },

0 commit comments

Comments
 (0)