generated from release-it/plugin-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (22 loc) · 897 Bytes
/
index.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
import VersionPlugin from 'release-it/customExport_lib-plugin-version-Version.js';
import semver from 'semver';
class SnapshotPreReleaseVersionPlugin extends VersionPlugin {
static isEnabled(options) {
return options !== false;
}
incrementVersion(...args) {
const nextVersion = super.incrementVersion(...args);
const parsedVersion = semver.parse(nextVersion);
if (parsedVersion && parsedVersion.prerelease.length) {
if (parsedVersion.prerelease.length === 1 && typeof parsedVersion.prerelease[0] === 'number') {
parsedVersion.prerelease = ['SNAPSHOT'];
return parsedVersion.format();
} else if (typeof parsedVersion.prerelease[parsedVersion.prerelease.length - 1] === 'number') {
parsedVersion.prerelease.pop();
return parsedVersion.format();
}
}
return null;
}
}
export default SnapshotPreReleaseVersionPlugin;