1import { existsSync } from 'fs'; 2import { join } from 'path'; 3 4import { ConfigError } from './Errors'; 5 6export function getRootPackageJsonPath(projectRoot: string): string { 7 const packageJsonPath = join(projectRoot, 'package.json'); 8 if (!existsSync(packageJsonPath)) { 9 throw new ConfigError( 10 `The expected package.json path: ${packageJsonPath} does not exist`, 11 'MODULE_NOT_FOUND' 12 ); 13 } 14 return packageJsonPath; 15} 16