private extractVersion()

in src/targets/go.ts [334:355]


  private extractVersion(moduleDirectory: string): string {

    const versionFile = path.join(moduleDirectory, 'version');

    const repoVersion = this.version;
    const moduleVersion = fs.existsSync(versionFile) ? fs.readFileSync(versionFile).toString() : undefined;

    if (repoVersion && moduleVersion && repoVersion !== moduleVersion) {
      throw new Error(`Repo version (${repoVersion}) conflicts with module version (${moduleVersion}) for module in ${moduleDirectory}`);
    }

    // just take the one thats defined, they have to the same if both are.
    const version = moduleVersion ? moduleVersion : repoVersion;

    if (!version) {
      throw new Error(`Unable to determine version of module ${moduleDirectory}. `
        + "Either include a 'version' file, or specify a global version using the VERSION environment variable.");
    }

    return version;

  }