aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-19 01:22:31 +0800
committerFabio Berger <me@fabioberger.com>2018-06-19 05:08:44 +0800
commitdcd53c3c5bc251af242166cf758146649eb4185b (patch)
treef9c0401be6a3de8a5907e4a4425eccc8e0de844f /packages/monorepo-scripts/src/utils
parent3e64b3da398a90e6ddfc287ebf28ec780b64b56f (diff)
downloaddexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar.gz
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar.bz2
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar.lz
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar.xz
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.tar.zst
dexon-sol-tools-dcd53c3c5bc251af242166cf758146649eb4185b.zip
Use semver package instead of getNextPatchVersion
Diffstat (limited to 'packages/monorepo-scripts/src/utils')
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts
index 16a84b869..20bc57bae 100644
--- a/packages/monorepo-scripts/src/utils/utils.ts
+++ b/packages/monorepo-scripts/src/utils/utils.ts
@@ -1,6 +1,7 @@
import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import { exec as execAsync } from 'promisify-child-process';
+import semver = require('semver');
import { constants } from '../constants';
import { GitTagsByPackageName, UpdatedPackage } from '../types';
@@ -37,15 +38,19 @@ export const utils = {
packageName: string,
packageLocation: string,
): Promise<string> {
- let nextVersion;
+ let nextVersionIfValid;
const changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, packageLocation);
if (_.isEmpty(changelog)) {
- nextVersion = this.getNextPatchVersion(currentVersion);
+ nextVersionIfValid = semver.inc(currentVersion, 'patch');
}
const lastEntry = changelog[0];
- nextVersion =
- lastEntry.version === currentVersion ? this.getNextPatchVersion(currentVersion) : lastEntry.version;
- return nextVersion;
+ nextVersionIfValid = semver.eq(lastEntry.version, currentVersion)
+ ? semver.inc(currentVersion, 'patch')
+ : lastEntry.version;
+ if (_.isNull(nextVersionIfValid)) {
+ throw new Error(`Encountered invalid semver: ${currentVersion} associated with ${packageName}`);
+ }
+ return nextVersionIfValid;
},
async getRemoteGitTagsAsync(): Promise<string[]> {
const result = await execAsync(`git ls-remote --tags`, {