aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/convert_changelogs.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/monorepo-scripts/src/convert_changelogs.ts')
-rw-r--r--packages/monorepo-scripts/src/convert_changelogs.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/monorepo-scripts/src/convert_changelogs.ts b/packages/monorepo-scripts/src/convert_changelogs.ts
index c62cf844b..f4c4d51a2 100644
--- a/packages/monorepo-scripts/src/convert_changelogs.ts
+++ b/packages/monorepo-scripts/src/convert_changelogs.ts
@@ -10,6 +10,7 @@ import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import * as moment from 'moment';
import * as path from 'path';
+import { exec as execAsync } from 'promisify-child-process';
import { constants } from './constants';
import { Changelog, Changes, UpdatedPackage } from './types';
@@ -20,7 +21,7 @@ const HEADER_PRAGMA = '##';
(async () => {
const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
const publicLernaPackages = _.filter(allLernaPackages, pkg => !pkg.package.private);
- _.each(publicLernaPackages, lernaPackage => {
+ for (const lernaPackage of publicLernaPackages) {
const changelogMdIfExists = getChangelogMdIfExists(lernaPackage.package.name, lernaPackage.location);
if (_.isUndefined(changelogMdIfExists)) {
throw new Error(`${lernaPackage.package.name} should have CHANGELOG.md b/c it's public. Add one.`);
@@ -76,9 +77,13 @@ const HEADER_PRAGMA = '##';
changelog.changes.push(changes);
}
}
- const changelogJson = JSON.stringify(changelogs, null, '\t');
- fs.writeFileSync(`${lernaPackage.location}/CHANGELOG.json`, changelogJson);
- });
+ const changelogJson = JSON.stringify(changelogs);
+ const changelogJsonPath = `${lernaPackage.location}/CHANGELOG.json`;
+ fs.writeFileSync(changelogJsonPath, changelogJson);
+ await execAsync(`prettier --write ${changelogJsonPath} --config .prettierrc`, {
+ cwd: constants.monorepoRootPath,
+ });
+ }
})().catch(err => {
utils.log(err.stdout);
process.exit(1);