function validateVersion()

in scripts/updateVersion.ts [37:57]


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

    const constantsVersion = getVersion(constantsPath, constantsVersionRegex);

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

    const parsedVersion = semver.parse(packageJsonVersion);

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