git-watchtower 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -8,17 +8,33 @@ const { version: currentVersion } = require('../../package.json');
8
8
 
9
9
  /**
10
10
  * Compare two semver version strings
11
+ * Handles missing segments (treated as 0), >3-part versions,
12
+ * and prerelease suffixes (e.g. 1.8.0-beta.1 < 1.8.0).
11
13
  * @param {string} a - First version (e.g. '1.8.0')
12
14
  * @param {string} b - Second version (e.g. '1.7.0')
13
15
  * @returns {number} 1 if a > b, -1 if a < b, 0 if equal
14
16
  */
15
17
  function compareVersions(a, b) {
16
- const pa = a.split('.').map(Number);
17
- const pb = b.split('.').map(Number);
18
- for (let i = 0; i < 3; i++) {
19
- if (pa[i] > pb[i]) return 1;
20
- if (pa[i] < pb[i]) return -1;
18
+ // Split off prerelease suffix (e.g. '1.8.0-beta.1' → core='1.8.0', pre='beta.1')
19
+ const [coreA, preA] = a.split('-', 2);
20
+ const [coreB, preB] = b.split('-', 2);
21
+
22
+ const pa = coreA.split('.').map(Number);
23
+ const pb = coreB.split('.').map(Number);
24
+ const len = Math.max(pa.length, pb.length);
25
+
26
+ for (let i = 0; i < len; i++) {
27
+ const na = pa[i] || 0;
28
+ const nb = pb[i] || 0;
29
+ if (na > nb) return 1;
30
+ if (na < nb) return -1;
21
31
  }
32
+
33
+ // Core versions are equal — check prerelease.
34
+ // A version with a prerelease tag is less than one without (semver §11).
35
+ if (preA && !preB) return -1;
36
+ if (!preA && preB) return 1;
37
+
22
38
  return 0;
23
39
  }
24
40