Bläddra i källkod

Abort if lerna version didn’t commit.

Jason Grout 6 år sedan
förälder
incheckning
320300b59f
2 ändrade filer med 42 tillägg och 0 borttagningar
  1. 21 0
      buildutils/src/bumpversion.ts
  2. 21 0
      buildutils/src/patch-release.ts

+ 21 - 0
buildutils/src/bumpversion.ts

@@ -60,7 +60,28 @@ commander
     if (opts.force) {
       cmd += ' --yes';
     }
+
+    let oldVersion = utils.run(
+      'git rev-parse HEAD',
+      {
+        stdio: 'pipe',
+        encoding: 'utf8'
+      },
+      true
+    );
     utils.run(cmd);
+    let newVersion = utils.run(
+      'git rev-parse HEAD',
+      {
+        stdio: 'pipe',
+        encoding: 'utf8'
+      },
+      true
+    );
+    if (oldVersion === newVersion) {
+      // lerna didn't version anything, so we assume the user aborted
+      throw new Error('Lerna aborted');
+    }
 
     // Our work is done if this is a major or minor bump.
     if (spec in ['major', 'minor']) {

+ 21 - 0
buildutils/src/patch-release.ts

@@ -28,7 +28,28 @@ commander
       if (options.force) {
         cmd += ' --yes';
       }
+      let oldVersion = utils.run(
+        'git rev-parse HEAD',
+        {
+          stdio: 'pipe',
+          encoding: 'utf8'
+        },
+        true
+      );
       utils.run(cmd);
+      let newVersion = utils.run(
+        'git rev-parse HEAD',
+        {
+          stdio: 'pipe',
+          encoding: 'utf8'
+        },
+        true
+      );
+      if (oldVersion === newVersion) {
+        console.log('aborting');
+        // lerna didn't version anything, so we assume the user aborted
+        throw new Error('Lerna aborted');
+      }
     }
 
     // Patch the python version