cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2d51afdcabc76566fefef0ec43ae4a87283ae44b

Branches

Tags

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

Clone

HTTPS

Download ZIP

scripts/check-version.cjs

20lines · modecode

1const fs = require('fs');
2const path = require('path');
3
4const main = () => {
5 const pkg = require('../package.json');
6 const version = pkg['version'];
7 if (!version) throw 'The version property is not set in the package.json file';
8 if (typeof version !== 'string') {
9 throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`;
10 }
11
12 const versionFile = path.resolve(__dirname, '..', 'src', 'version.ts');
13 const contents = fs.readFileSync(versionFile, 'utf8');
14 const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`);
15 fs.writeFileSync(versionFile, output);
16};
17
18if (require.main === module) {
19 main();
20}
21