Open History to see the last commit
1import { readFileSync } from 'node:fs'
2import { join } from 'node:path'
3β
4let packageName: string | undefined
5β
6export function getPackageName() {
7 if (!packageName) {
8 const packageJson = JSON.parse(
9 readFileSync(join(process.cwd(), 'package.json'), 'utf-8'),
10 ) as { name: string }
11β
12 packageName = packageJson.name
13 }
14β
15 return packageName
16}