2021-06-09 16:51:56 +02:00
|
|
|
// @ts-ignore internal module
|
2021-06-16 14:01:48 +02:00
|
|
|
import Runner from 'jscodeshift/src/Runner'
|
2021-06-09 16:51:56 +02:00
|
|
|
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
}
|