import type { PackageJSON } from '../types' ; export const replaceDependency = ( { packageJSON , from , to , } ) => { const deps = packageJSON . dependencies ; const devDeps = packageJSON . devDependencies ; const [ key , value ] = to || [ ] ; if ( deps ) { if ( deps [ from ] ) { delete packageJSON . dependencies [ from ] ; if ( key && ! deps [ key ] ) { packageJSON . dependencies [ key ] = value ; } } } if ( devDeps ) { if ( devDeps [ from ] ) { delete packageJSON . devDependencies [ from ] ; if ( key && ! devDeps [ key ] ) { packageJSON . devDependencies [ key ] = value ; } } } } ;