microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
f46fff4e5103217703b51e27ba3f6405ac000e21

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

pipelines/scripts/updatePackageVersion.js

31lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4import fs from "node:fs";
5
6const prereleaseVersion = process.argv[2];
7const packageJsonContent = fs.readFileSync("./package.json", "utf-8");
8const packageJson = JSON.parse(packageJsonContent);
9const currentVersion = packageJson.version;
10
11if (currentVersion === undefined) {
12 console.error(`${packageJson.name}: Current version is undefined in package.json`);
13 process.exit(1);
14}
15
16if (prereleaseVersion === undefined) {
17 console.error(
18 `${packageJson.name}: Prerelease version argument is missing. Usage: node updatePackageVersion.js <prerelease-version>`,
19 );
20 process.exit(1);
21}
22
23const newVersion = `${currentVersion}-${prereleaseVersion}`;
24packageJson.version = newVersion;
25
26fs.writeFileSync(
27 "./package.json",
28 JSON.stringify(packageJson, null, 2) + "\n",
29);
30
31console.log(`${packageJson.name}: Package version updated to '${newVersion}'`);