Semver库为我提供了0.0.001的无效版本

时间:2018-07-14 01:52:31

标签: node.js npm semantic-versioning

我有这段代码:

  const semver = require('semver');

  let oldestVersion = '0.0.001';
  let youngestVersion = '9999.99.999';
  let youngestPackageName = null;
  let oldestPackageName = null;

  Object.keys(confirmProjects).forEach(k => {
    const v = confirmProjects[k];

    if (semver.lte(v.localVersion, youngestVersion)) {  // fails here
      youngestVersion = v.localVersion;
      youngestPackageName = v.name;
    }

    if (semver.gte(v.localVersion, oldestVersion)) {
      oldestVersion = v.localVersion;
      oldestPackageName = v.name;
    }
  });

错误是:

TypeError: Invalid Version: 0.0.001
    at new SemVer (/home/oleg/WebstormProjects/oresoftware/npp/node_modules/semver/semver.js:305:11)
    at compare (/home/oleg/WebstormProjects/oresoftware/npp/node_modules/semver/semver.js:578:39)
    at Function.gte (/home/oleg/WebstormProjects/oresoftware/npp/node_modules/semver/semver.js:627:10)

有人知道如何减轻这种情况,或者我的cdoe可能出什么毛病吗?

2 个答案:

答案 0 :(得分:2)

您的版本无效。应该改为pd.read_table

如果您需要三位数字来进行修订,则可以稍后使用它们……apply(pd.to_numeric)0.0.1之后。 0.0.90.0.10等之后

答案 1 :(得分:-1)

这很愚蠢,但我想这是semver的工作方式。

这是无效的:

0.0.99

但这是有效的:

0.0.100