diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-02 14:53:31 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-02 14:53:31 +0800 |
commit | 3f230a8fdbca3728a4d6b1677d776b8e0dbbae6a (patch) | |
tree | 49dc4031787929b015b25e0f70aa94ee4fe24050 /packages/monorepo-scripts | |
parent | 2a6a71ea6cd89d39142f51530d06e80ffc44e722 (diff) | |
download | dexon-0x-contracts-3f230a8fdbca3728a4d6b1677d776b8e0dbbae6a.tar.gz dexon-0x-contracts-3f230a8fdbca3728a4d6b1677d776b8e0dbbae6a.tar.zst dexon-0x-contracts-3f230a8fdbca3728a4d6b1677d776b8e0dbbae6a.zip |
Move prettify command to utils and also call it on CHANGELOG.md
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/src/convert_changelogs.ts | 10 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 5 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/utils.ts | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/packages/monorepo-scripts/src/convert_changelogs.ts b/packages/monorepo-scripts/src/convert_changelogs.ts index f4c4d51a2..71383ee7c 100644 --- a/packages/monorepo-scripts/src/convert_changelogs.ts +++ b/packages/monorepo-scripts/src/convert_changelogs.ts @@ -77,12 +77,10 @@ const HEADER_PRAGMA = '##'; changelog.changes.push(changes); } } - 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, - }); + const changelogJSONPath = JSON.stringify(changelogs); + const changelogJSONPathPath = `${lernaPackage.location}/CHANGELOG.json`; + fs.writeFileSync(changelogJSONPathPath, changelogJSONPath); + await utils.prettifyAsync(changelogJSONPath, constants.monorepoRootPath); } })().catch(err => { utils.log(err.stdout); diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 2263e2f8c..30e5bd0e1 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -78,14 +78,13 @@ const semverNameToIndex: { [semver: string]: number } = { // Save updated CHANGELOG.json fs.writeFileSync(changelogJSONPath, JSON.stringify(changelogs)); - await execAsync(`prettier --write ${changelogJSONPath} --config .prettierrc`, { - cwd: constants.monorepoRootPath, - }); + await utils.prettifyAsync(changelogJSONPath, constants.monorepoRootPath); utils.log(`${packageName}: Updated CHANGELOG.json`); // Generate updated CHANGELOG.md const changelogMd = generateChangelogMd(changelogs); const changelogMdPath = path.join(lernaPackage.location, 'CHANGELOG.md'); fs.writeFileSync(changelogMdPath, changelogMd); + await utils.prettifyAsync(changelogMdPath, constants.monorepoRootPath); utils.log(`${packageName}: Updated CHANGELOG.md`); } diff --git a/packages/monorepo-scripts/src/utils.ts b/packages/monorepo-scripts/src/utils.ts index 73f6260d3..9aa37e272 100644 --- a/packages/monorepo-scripts/src/utils.ts +++ b/packages/monorepo-scripts/src/utils.ts @@ -1,4 +1,5 @@ import * as _ from 'lodash'; +import { exec as execAsync, spawn } from 'promisify-child-process'; export const utils = { log(...args: any[]): void { @@ -11,4 +12,9 @@ export const utils = { const newPatchVersion = `${versionSegments[0]}.${versionSegments[1]}.${newPatch}`; return newPatchVersion; }, + async prettifyAsync(filePath: string, cwd: string) { + await execAsync(`prettier --write ${filePath} --config .prettierrc`, { + cwd, + }); + }, }; |