poad 2.6.0 → 2.6.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/poad.js +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poad",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "engine": "0.6.1",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
package/poad.js CHANGED
@@ -462,6 +462,18 @@ const display = (commands) => {
462
462
  }
463
463
  };
464
464
 
465
+ // True when version `a` is strictly newer than `b` (major.minor.patch).
466
+ const isNewerVersion = (a, b) => {
467
+ const pa = String(a).split('.').map(Number);
468
+ const pb = String(b).split('.').map(Number);
469
+ for (let i = 0; i < 3; i++) {
470
+ const x = pa[i] || 0;
471
+ const y = pb[i] || 0;
472
+ if (x !== y) return x > y;
473
+ }
474
+ return false;
475
+ };
476
+
465
477
  // Main function.
466
478
  const main = async () => {
467
479
  let version = await checkVersion();
@@ -470,9 +482,7 @@ const main = async () => {
470
482
  if (version === null) {
471
483
  version = current_version;
472
484
  }
473
- const cv = current_version.replace(/\./g, '') * 1;
474
- const v = version.replace(/\./g, '') * 1;
475
- if (v > cv) {
485
+ if (isNewerVersion(version, current_version)) {
476
486
  const message =
477
487
  `A new version (${version}) is available. You can upgrade by running:\n` +
478
488
  chalk.white.bold(`npm i -g poad@${version}`);