From 8d8d2f07b84e68937c72d9d3b08362eefae81aa7 Mon Sep 17 00:00:00 2001 From: Pedro Cattori Date: Mon, 23 Jan 2023 10:10:45 -0500 Subject: [PATCH] refactor(dev): simplifications (#5220) --- packages/remix-dev/compiler/utils/fs.ts | 14 -------------- packages/remix-dev/config.ts | 14 ++++++-------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/packages/remix-dev/compiler/utils/fs.ts b/packages/remix-dev/compiler/utils/fs.ts index bf38d480a6e..c64ac06227d 100644 --- a/packages/remix-dev/compiler/utils/fs.ts +++ b/packages/remix-dev/compiler/utils/fs.ts @@ -9,17 +9,3 @@ export async function writeFileSafe( await fsp.writeFile(file, contents); return file; } - -export async function writeFilesSafe( - files: { file: string; contents: string }[] -): Promise { - return Promise.all( - files.map(({ file, contents }) => writeFileSafe(file, contents)) - ); -} - -export async function createTemporaryDirectory( - baseDir: string -): Promise { - return fsp.mkdtemp(path.join(baseDir, "remix-")); -} diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index c41db0e614e..c2a5ef25735 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -307,14 +307,14 @@ export async function readConfig( remixRoot?: string, serverMode = ServerMode.Production ): Promise { - if (!remixRoot) { - remixRoot = process.env.REMIX_ROOT || process.cwd(); - } - if (!isValidServerMode(serverMode)) { throw new Error(`Invalid server mode "${serverMode}"`); } + if (!remixRoot) { + remixRoot = process.env.REMIX_ROOT || process.cwd(); + } + let rootDirectory = path.resolve(remixRoot); let configFile = findConfig(rootDirectory, "remix.config"); @@ -450,15 +450,13 @@ export async function readConfig( appDirectory, appConfig.ignoredRouteFiles ); - for (let key of Object.keys(conventionalRoutes)) { - let route = conventionalRoutes[key]; + for (let route of Object.values(conventionalRoutes)) { routes[route.id] = { ...route, parentId: route.parentId || "root" }; } } if (appConfig.routes) { let manualRoutes = await appConfig.routes(defineRoutes); - for (let key of Object.keys(manualRoutes)) { - let route = manualRoutes[key]; + for (let route of Object.values(manualRoutes)) { routes[route.id] = { ...route, parentId: route.parentId || "root" }; } }