forked from abpframework/abp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish-utils.js
25 lines (20 loc) · 932 Bytes
/
publish-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const { program } = require('commander');
const fse = require('fs-extra');
const semverParse = require('semver/functions/parse');
program.version('0.0.1');
program.option('-n, --nextVersion', 'version in common.props');
program.option('-pr, --prerelease', 'whether version is prerelease');
program.option('-cv, --customVersion <customVersion>', 'set exact version');
program.parse(process.argv);
if (program.nextVersion) console.log(getVersion());
if (program.prerelease)
console.log(!!semverParse(getVersion()).prerelease?.length);
function getVersion() {
if (program.customVersion) return program.customVersion;
const commonProps = fse.readFileSync('../common.props').toString();
const versionTag = '<Version>';
const versionEndTag = '</Version>';
const first = commonProps.indexOf(versionTag) + versionTag.length;
const last = commonProps.indexOf(versionEndTag);
return commonProps.substring(first, last);
}