rsnext/packages/next-codemod/lib/run-jscodeshift.ts
JJ Kasper dde9ad46ad
Add experimental cra-to-next transform in codemod cli (#24969)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-09 16:51:56 +02:00

19 lines
551 B
TypeScript

// @ts-ignore internal module
import Runner from 'jscodeshift/src/runner'
export default function runJscodeshift(
transformerPath: string,
flags: { [key: string]: any },
files: string[]
) {
// we run jscodeshift in the same process to be able to
// share state between the main CRA transform and sub-transforms
return Runner.run(transformerPath, files, {
ignorePattern: ['**/node_modules/**', '**/.next/**', '**/build/**'],
extensions: 'tsx,ts,jsx,js',
parser: 'tsx',
verbose: 2,
runInBand: true,
...flags,
})
}