function validateVersion()

in scripts/updateVersion.ts [36:59]


function validateVersion(): string {
    const packageJson = readJSONSync(packageJsonPath);
    const packageJsonVersion = packageJson.version;

    const nuspecVersion = getVersion(nuspecPath, nuspecVersionRegex);

    const constantsVersion = getVersion(constantsPath, constantsVersionRegex);

    console.log('Found the following versions:');
    console.log(`- package.json: ${packageJsonVersion}`);
    console.log(`- Worker.nuspec: ${nuspecVersion}`);
    console.log(`- src/constants.ts: ${constantsVersion}`);

    const parsedVersion = semver.parse(packageJsonVersion);

    if (!packageJsonVersion || !nuspecVersion || !constantsVersion || !parsedVersion) {
        throw new Error('Failed to detect valid versions in all expected files');
    } else if (nuspecVersion !== packageJsonVersion || constantsVersion !== packageJsonVersion) {
        throw new Error(`Worker versions do not match.`);
    } else {
        console.log('Versions match! 🎉');
        return packageJsonVersion;
    }
}