sibartlett/homebridge-wink3

Version check fails with snap version of Homebridge

pelaxa opened this issue · 0 comments

I am using snap to install home bridge: https://github.com/kubiko/homebridge-snap
and it works great, except that whenever I update this plugin, I have to manually update the code so the version check passes.

Running:
npm view [package] version

returns two lines on this version like below:

HOMEBRIDGE_AUTO_UPDATE_NPM_MODULES=on (default value)
2.0.0

This causes the version check to fail. My quick fix is to change the the check version method like below:

checkVersion() {
    childProcess.exec(`npm view ${pkg.name} version`, (error, stdout) => {
      const latestVersion = stdout && stdout.trim().match(/\d*\.\d*\.\d*/g)[0];
      if (latestVersion && compareVersions(latestVersion, pkg.version) > 0) {
        this.log.warn(
          `NOTICE: New version of ${pkg.name} available: ${latestVersion}`
        );
      }
    });
  }