import util from 'util' ; import fs from 'fs' ; import jscodeshift from 'jscodeshift' ; const readFile = util . promisify ( fs . readFile ) ; const empty = ( ) => { } ; const stats = ( name , quantity ) => { quantity = typeof quantity !== 'number' ? 1 : quantity ; console . log ( 'update: ' , { name , quantity } ) ; } ; const report = ( ) => { } ; const parser = 'tsx' ; const j = jscodeshift . withParser ( parser ) ; export const runCodemodFile = async ( codemodFn , filename ) => { const content = await readFile ( filename ) ; const source = content . toString ( ) ; const options = { } ; return codemodFn ( { path : filename , source } , { j , jscodeshift : j , stats : options . dry ? stats : empty , report : ( msg ) => report ( file , msg ) } , options ) ; } ;