Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

getPackageName.ts

16 lines359 Bytes

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