From d7c19c58eb87c1f7666f2469766e8e54fa7ff470 Mon Sep 17 00:00:00 2001 From: Matej Lednicky Date: Wed, 15 Mar 2023 20:21:34 +0100 Subject: [PATCH] use version 0.0.1 as default When no version is provided in package manifest (eg. project is using semantic release) use 0.0.1 as default --- src/pkg.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pkg.ts b/src/pkg.ts index fa5d8f6..28e52dc 100644 --- a/src/pkg.ts +++ b/src/pkg.ts @@ -59,14 +59,20 @@ 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) { console.log( 'Package manifest', packagePath, - 'should contain name and version.' + 'should contain name' ) return null } + if (!pkg.version) { + console.log( + 'No version found in package manifest, using 0.0.1' + ) + pkg.version = '0.0.1' + } const indent = getIndent(fileData) || ' ' pkg.__Indent = indent return pkg