Skip to content

Commit

Permalink
refactor(dev): simplifications (#5220)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori authored Jan 23, 2023
1 parent c08f30f commit 8d8d2f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
14 changes: 0 additions & 14 deletions packages/remix-dev/compiler/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]> {
return Promise.all(
files.map(({ file, contents }) => writeFileSafe(file, contents))
);
}

export async function createTemporaryDirectory(
baseDir: string
): Promise<string> {
return fsp.mkdtemp(path.join(baseDir, "remix-"));
}
14 changes: 6 additions & 8 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ export async function readConfig(
remixRoot?: string,
serverMode = ServerMode.Production
): Promise<RemixConfig> {
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");

Expand Down Expand Up @@ -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" };
}
}
Expand Down

0 comments on commit 8d8d2f0

Please sign in to comment.