From 1b149ef98dca4f7306f6276f8214ff85edc720d8 Mon Sep 17 00:00:00 2001 From: Percy Ma Date: Thu, 15 Sep 2022 17:58:18 +0800 Subject: [PATCH] fix: `readPackageJSON` and `readPackageJSON` can be called without id (#39) --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 23c6832..5366eff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ export function defineTSConfig (tsconfig: TSConfig): TSConfig { return tsconfig } -export async function readPackageJSON (id: string, opts: ResolveOptions = {}): Promise { +export async function readPackageJSON (id?: string, opts: ResolveOptions = {}): Promise { const resolvedPath = await resolvePackageJSON(id, opts) const blob = await fsp.readFile(resolvedPath, 'utf-8') return JSON.parse(blob) as PackageJson @@ -28,7 +28,7 @@ export async function writePackageJSON (path: string, pkg: PackageJson): Promise await fsp.writeFile(path, JSON.stringify(pkg, null, 2)) } -export async function readTSConfig (id: string, opts: ResolveOptions = {}): Promise { +export async function readTSConfig (id?: string, opts: ResolveOptions = {}): Promise { const resolvedPath = await resolveTSConfig(id, opts) const blob = await fsp.readFile(resolvedPath, 'utf-8') const jsonc = await import('jsonc-parser')