From cdb68d4e180e70b25fa1b9378ea9cbfcf3bc4123 Mon Sep 17 00:00:00 2001 From: aldousalvarez Date: Wed, 2 Nov 2022 15:07:49 +0800 Subject: [PATCH] fix(build): sync-ts-config script needs import assertion of type json Fixes #2163 Signed-off-by: aldousalvarez --- tools/sync-npm-deps-to-tsc-projects.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/sync-npm-deps-to-tsc-projects.ts b/tools/sync-npm-deps-to-tsc-projects.ts index 09cf38e7276..93024ae2866 100644 --- a/tools/sync-npm-deps-to-tsc-projects.ts +++ b/tools/sync-npm-deps-to-tsc-projects.ts @@ -5,7 +5,7 @@ import JSON5 from "json5"; import fs from "fs-extra"; import { globby, Options as GlobbyOptions } from "globby"; import { RuntimeError } from "run-time-error"; -import lernaJson from "../lerna.json"; +import { readFile } from "fs/promises"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -19,16 +19,19 @@ const main = async (argv: string[], env: NodeJS.ProcessEnv) => { } const TS_CONFIG = "tsconfig.json"; const PACKAGE_JSON = "package.json"; + const LERNA_JSON = "lerna.json"; const SCRIPT_DIR = __dirname; const PROJECT_DIR = path.join(SCRIPT_DIR, "../"); console.log(`SCRIPT_DIR=${SCRIPT_DIR}`); console.log(`PROJECT_DIR=${PROJECT_DIR}`); - - const pkgJsonGlobPatterns = lernaJson.packages.map((it) => + const lernaJson = JSON.parse( + await readFile(PROJECT_DIR + LERNA_JSON, "utf-8"), + ); + const pkgJsonGlobPatterns = lernaJson.packages.map((it: string) => "./".concat(it).concat(`/${PACKAGE_JSON}`), ); - const tsConfigJsonGlobPatterns = lernaJson.packages.map((it) => + const tsConfigJsonGlobPatterns = lernaJson.packages.map((it: string) => "./".concat(it).concat(`/${TS_CONFIG}`), ); console.log("Globbing lerna package patterns: ", pkgJsonGlobPatterns);