How to use the semver-parser.compareSemVer function in semver-parser

To help you get started, we’ve selected a few semver-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asamuzaK / webExtNativeMsg / modules / file-util.js View on Github external
const removeDir = (dir, baseDir) => {
  if (isDir(dir)) {
    if (!isSubDir(dir, baseDir)) {
      throw new Error(`${dir} is not a subdirectory of ${baseDir}.`);
    }
    // NOTE: remove version detection when node 10 reaches EOL
    const {version: nodeVersion} = process;
    const result = compareSemVer(nodeVersion, "12.10.0");
    if (result >= 0) {
      fs.rmdirSync(dir, {recursive: true});
    } else {
      const files = fs.readdirSync(dir);
      files.length && files.forEach(file => {
        const cur = path.join(dir, file);
        if (fs.lstatSync(cur).isDirectory()) {
          removeDir(cur, baseDir);
        } else {
          fs.unlinkSync(cur);
        }
      });
      fs.rmdirSync(dir);
    }
  }
};
github asamuzaK / webExtNativeMsg / modules / file-util.js View on Github external
const convertUriToFilePath = uri => {
  if (!isString(uri)) {
    throw new TypeError(`Expected String but got ${getType(uri)}.`);
  }
  const {protocol, pathname} = new URL(uri);
  let file;
  if (protocol === "file:" && pathname) {
    // NOTE: remove version detection when node 10 reaches EOL
    const {version: nodeVersion} = process;
    const result = compareSemVer(nodeVersion, "10.16.0");
    if (result >= 0) {
      file = fileURLToPath(uri);
    } else {
      file = IS_WIN && path.normalize(decodeURIComponent(pathname).slice(1)) ||
             decodeURIComponent(pathname);
    }
  }
  return file || null;
};
github ElasticHQ / elasticsearch-HQ / ui / src / components / footer / footer.controller.js View on Github external
parseVersions() {
        this.installed_version = this.dataSet.installed_version;

        let latestStable = this.dataSet.current_stable_version;
        // For Testing
        //latestStable = "2.8.0"; //-beta.30";


        let html = '';
        // See https://github.com/asamuzaK/semverParser
        //  for details available 
        let outcome = compareSemVer(latestStable, this.installed_version)

        if (!!outcome) {
            // See if difference is simple a Patch, or something larger
            let latest = parseSemVer(latestStable);
            let installed = parseSemVer(this.installed_version);

            html = `Installed Version: <b>${this.installed_version}</b>. Latest version: `;
            if (latest.major &gt; installed.major) {
                html += `<span class="alert alert-danger mini-alert">${latestStable}</span>`
            } else if (latest.minor &gt; installed.minor) {
                html += `<span class="alert alert-danger mini-alert">${latestStable}</span>`
            } else if (latest.patch &gt; installed.patch) {
                html += `<span class="alert alert-warning mini-alert">${latestStable}</span>`
            } else {
                // This would normally be beta releases
                html += `<span class="alert alert-info mini-alert">${latestStable}</span>`
github asamuzaK / withExEditorHost / modules / main.js View on Github external
const exportHostVersion = async minVer => {
  if (!isString(minVer)) {
    throw new TypeError(`Expected String but got ${getType(minVer)}.`);
  }
  if (!isValidSemVer(minVer)) {
    throw new Error(`${minVer} is not valid SemVer.`);
  }
  const result = await compareSemVer(hostVersion, minVer);
  const latest = await getLatestHostVersion();
  let isLatest;
  if (latest) {
    const currentResult = await compareSemVer(hostVersion, latest);
    isLatest = currentResult >= 0;
  }
  const msg = {
    [HOST_VERSION]: {
      isLatest,
      latest,
      result,
    },
  };
  const func = writeStdout(msg);
  return func;
};
github asamuzaK / withExEditorHost / modules / main.js View on Github external
const exportHostVersion = async minVer => {
  if (!isString(minVer)) {
    throw new TypeError(`Expected String but got ${getType(minVer)}.`);
  }
  if (!isValidSemVer(minVer)) {
    throw new Error(`${minVer} is not valid SemVer.`);
  }
  const result = await compareSemVer(hostVersion, minVer);
  const latest = await getLatestHostVersion();
  let isLatest;
  if (latest) {
    const currentResult = await compareSemVer(hostVersion, latest);
    isLatest = currentResult >= 0;
  }
  const msg = {
    [HOST_VERSION]: {
      isLatest,
      latest,
      result,
    },
  };
  const func = writeStdout(msg);
  return func;
};

semver-parser

SemVer parser. parse, verify, compare SemVer.

MIT
Latest version published 26 days ago

Package Health Score

67 / 100
Full package analysis

Similar packages