diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-18 22:55:59 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-19 05:06:32 +0800 |
commit | 8633fa702436cceeafa52ec39a7fabb5b2650c38 (patch) | |
tree | 0702ff5b590396e86f71508a16a87b7440ffe0c0 /packages/monorepo-scripts/src/publish.ts | |
parent | 19668b9b48eb08645f500dd8453b8cb2f7abc400 (diff) | |
download | dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar.gz dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar.bz2 dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar.lz dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar.xz dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.tar.zst dexon-sol-tools-8633fa702436cceeafa52ec39a7fabb5b2650c38.zip |
Add more prepublish checks
Diffstat (limited to 'packages/monorepo-scripts/src/publish.ts')
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 2efbc8bf2..637512a5a 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -119,19 +119,14 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]) const packageToVersionChange: PackageToVersionChange = {}; for (const lernaPackage of updatedPublicLernaPackages) { const packageName = lernaPackage.package.name; - const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json'); - const changelogJSON = utils.getChangelogJSONOrCreateIfMissing(changelogJSONPath); - let changelog: Changelog; - try { - changelog = JSON.parse(changelogJSON); - } catch (err) { - throw new Error( - `${lernaPackage.package.name}'s CHANGELOG.json contains invalid JSON. Please fix and try again.`, - ); - } + let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, lernaPackage.location); const currentVersion = lernaPackage.package.version; - const shouldAddNewEntry = changelogUtils.shouldAddNewChangelogEntry(currentVersion, changelog); + const shouldAddNewEntry = changelogUtils.shouldAddNewChangelogEntry( + lernaPackage.package.name, + currentVersion, + changelog, + ); if (shouldAddNewEntry) { // Create a new entry for a patch version with generic changelog entry. const nextPatchVersion = utils.getNextPatchVersion(currentVersion); @@ -160,14 +155,11 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]) } // Save updated CHANGELOG.json - fs.writeFileSync(changelogJSONPath, JSON.stringify(changelog, null, '\t')); - await utils.prettifyAsync(changelogJSONPath, constants.monorepoRootPath); + await changelogUtils.writeChangelogJsonFileAsync(lernaPackage.location, changelog); utils.log(`${packageName}: Updated CHANGELOG.json`); // Generate updated CHANGELOG.md const changelogMd = changelogUtils.generateChangelogMd(changelog); - const changelogMdPath = path.join(lernaPackage.location, 'CHANGELOG.md'); - fs.writeFileSync(changelogMdPath, changelogMd); - await utils.prettifyAsync(changelogMdPath, constants.monorepoRootPath); + await changelogUtils.writeChangelogMdFileAsync(lernaPackage.location, changelog); utils.log(`${packageName}: Updated CHANGELOG.md`); } |