forked from family/connectkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
18 lines (15 loc) · 761 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
* This script is used to copy over the version number in the package.json to
* the CONNECTKIT_VERSION constant in the index.ts file. This is done to
* ensure that the version number attribute on the ConnectKit wrapper is always
* up to date with the version number in the package.json file.
*/
const fs = require('fs');
const config = require('./packages/connectkit/package.json');
const file = fs.readFileSync('packages/connectkit/src/index.ts', 'utf8');
const lines = file.split('\n');
const versionLine = lines.findIndex((line) =>
line.includes('export const CONNECTKIT_VERSION = ')
);
lines[versionLine] = `export const CONNECTKIT_VERSION = '${config.version}';`;
fs.writeFileSync('packages/connectkit/src/index.ts', lines.join('\n'), 'utf8');