From 9098268ec48f1726471aa46f76c3033156080ac7 Mon Sep 17 00:00:00 2001 From: Elay Gelbart Date: Tue, 21 May 2024 15:23:02 +0300 Subject: [PATCH] fix: Add clear error message for missing 'version' in package.json This commit introduces error handling improvements for cases where the 'version' key is absent in package.json. Previously, the error thrown did not clearly indicate the issue was related to the missing 'version' key, leading to confusion. Now, the application checks for the 'version' key early in the command execution process and provides a clear and descriptive error message if it is not found. --- src/pkg.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg.ts b/src/pkg.ts index fa5d8f6..c750dc0 100644 --- a/src/pkg.ts +++ b/src/pkg.ts @@ -59,7 +59,7 @@ export function readPackageManifest(workingDir: string) { try { const fileData = fs.readFileSync(packagePath, 'utf-8') pkg = JSON.parse(fileData) as PackageManifest - if (!pkg.name && pkg.version) { + if (!pkg.name || !pkg.version) { console.log( 'Package manifest', packagePath,