import * as path from 'path' ; import { fs } from '@modern-js/utils' ; import execa from 'execa' ; import { LOCK_FILE } from '../constants' ; import { PackageManagerType } from '../parse-config' ; export const removeLockFile = ( rootPath , packageManager ) => { if ( packageManager === 'pnpm' ) { fs . removeSync ( path . join ( rootPath , LOCK_FILE . PNPM ) ) ; } else if ( packageManager === 'yarn' ) { fs . removeSync ( path . join ( rootPath , LOCK_FILE . YARN ) ) ; } else if ( packageManager === 'npm' ) { fs . removeSync ( path . join ( rootPath , LOCK_FILE . NPM ) ) ; } } ; export const installByPackageManager = async ( packageManager , { rootPath , removeLock } ) => { if ( removeLock ) { removeLockFile ( rootPath , packageManager ) ; } if ( packageManager === 'pnpm' ) { await execa ( 'pnpm' , [ 'install' ] , { stdio : 'inherit' } ) ; } if ( packageManager === 'yarn' ) { await execa ( 'yarn' , [ 'install' ] , { stdio : 'inherit' } ) ; } } ;