import * as fse from 'fs-extra' ; import * as upath from 'upath' ; export async function readPackageVersion ( packageName , dir ) { try { const packageJsonPath = upath . toUnix ( require . resolve ( packageName + "/package.json" , { paths : [ dir ] } ) ) ; if ( packageJsonPath . startsWith ( dir ) === false ) { return undefined ; } const packageJson = await fse . readJson ( packageJsonPath ) ; return packageJson . version ; } catch ( err ) { return undefined ; } }