import fs from 'fs' ; import { PackageJson } from './PackageJson' ; import path from 'path' ; const readPackageJson = function ( directory ) : PackageJson { const packageJsonPath = path . join ( directory , 'package.json' ) ; let name = '(unknown)' , version = '(unknown)' ; try { const data = fs . readFileSync ( packageJsonPath , { encoding : 'utf8' } ) ; const parsedData = JSON . parse ( data ) ; ( { name , version } = parsedData ) ; } catch { } return { name , version } ; } ; export { readPackageJson } ;