From 4ae1ff99f69792aabbcc324e60988dcc669580ea Mon Sep 17 00:00:00 2001
From: Shady Nagy <shadynagi@gmail.com>
Date: Tue, 8 Sep 2020 01:39:23 +0200
Subject: [PATCH 1/2] Update npm-publish.ts

This change to fix error if there is not any packages in the NPM as it is giving error on that function getLatestVersion and if the checkVersion flag set to false then no use to get version and compare.
---
 src/npm-publish.ts | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/npm-publish.ts b/src/npm-publish.ts
index a979ad0..afae40c 100644
--- a/src/npm-publish.ts
+++ b/src/npm-publish.ts
@@ -13,15 +13,22 @@ export async function npmPublish(opts: Options = {}): Promise<Results> {
 
   // Get the old and new version numbers
   let manifest = await readManifest(options.package, options.debug);
-  let publishedVersion = await npm.getLatestVersion(manifest.name, options);
-
-  // Determine if/how the version has changed
-  let diff = semver.diff(manifest.version, publishedVersion);
-
-  if (diff || !options.checkVersion) {
+  
+  //If checkVersion is false then publish.
+  if (!options.checkVersion) {
     // Publish the new version to NPM
     await npm.publish(manifest, options);
-  }
+  }else {
+    let publishedVersion = await npm.getLatestVersion(manifest.name, options);
+
+    // Determine if/how the version has changed
+    let diff = semver.diff(manifest.version, publishedVersion);
+
+    if (diff) {
+      // Publish the new version to NPM
+      await npm.publish(manifest, options);
+    }
+  }    
 
   let results: Results = {
     package: manifest.name,

From 64686eb1b39d739a0910e59a5477c68b4f1862cc Mon Sep 17 00:00:00 2001
From: Shady Nagy <shadynagi@gmail.com>
Date: Tue, 8 Sep 2020 10:28:16 +0200
Subject: [PATCH 2/2] Update npm-publish.ts

---
 src/npm-publish.ts | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/npm-publish.ts b/src/npm-publish.ts
index afae40c..e5efbce 100644
--- a/src/npm-publish.ts
+++ b/src/npm-publish.ts
@@ -13,12 +13,9 @@ export async function npmPublish(opts: Options = {}): Promise<Results> {
 
   // Get the old and new version numbers
   let manifest = await readManifest(options.package, options.debug);
-  
-  //If checkVersion is false then publish.
-  if (!options.checkVersion) {
-    // Publish the new version to NPM
-    await npm.publish(manifest, options);
-  }else {
+
+  // If checkVersion is false then publish.
+  if (options.checkVersion) {
     let publishedVersion = await npm.getLatestVersion(manifest.name, options);
 
     // Determine if/how the version has changed
@@ -28,13 +25,25 @@ export async function npmPublish(opts: Options = {}): Promise<Results> {
       // Publish the new version to NPM
       await npm.publish(manifest, options);
     }
-  }    
 
+    let results: Results = {
+      package: manifest.name,
+      type: diff || "none",
+      version: manifest.version.raw,
+      oldVersion: publishedVersion.raw,
+      dryRun: options.dryRun
+    };
+
+    options.debug("OUTPUT:", results);
+    return results;
+  }
+
+  await npm.publish(manifest, options);
   let results: Results = {
     package: manifest.name,
-    type: diff || "none",
+    type: "none",
     version: manifest.version.raw,
-    oldVersion: publishedVersion.raw,
+    oldVersion: "",
     dryRun: options.dryRun
   };