Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit beee952

Browse files
committed
ensure link-ts-references script prettiers files after writing them
1 parent 978fee4 commit beee952

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
docs/assets/launch.json linguist-language=JSON5
22
tsconfig-base.json linguist-language=JSON5
3+
tsconfig.json linguist-language=JSON5
34
.nycrc linguist-language=JSON
45
.prettierrc linguist-language=JSON
56
src/packages/ganache/api-extractor.json linguist-language=JSON5

scripts/link-ts-references.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { readFileSync, existsSync, writeFileSync } from "fs-extra";
77
import { resolve, join, relative, sep } from "path";
8+
import prettier from "prettier";
89

910
// using `require` because everything in scripts uses typescript's default
1011
// compiler settings, and these two modules require enabling `esModuleInterop`
@@ -133,11 +134,20 @@ function updateConfigs(configs: PackageInfo[]) {
133134
configs.forEach(updateConfig);
134135
}
135136

136-
function saveConfigs(configs: PackageInfo[]) {
137+
async function saveConfigs(configs: PackageInfo[]) {
138+
const prettierConfig = await prettier.resolveConfig(process.cwd());
137139
configs.forEach(({ modified, path, tsConfig }) => {
138140
if (modified) {
139141
const tsConfigFile = join(path, "tsconfig.json");
140-
writeFileSync(tsConfigFile, JSON5.stringify(tsConfig, null, 2));
142+
writeFileSync(
143+
tsConfigFile,
144+
prettier.format(JSON5.stringify(tsConfig, null, 2), {
145+
...prettierConfig,
146+
// neccessary as json5's default is to strip quotes
147+
quoteProps: "preserve",
148+
parser: "json5"
149+
})
150+
);
141151
}
142152
});
143153
}

0 commit comments

Comments
 (0)