-
-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: route gen ignores non js/ts(x) files
- Loading branch information
1 parent
6d7a5b3
commit b3409d4
Showing
3 changed files
with
56 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import path from 'path' | ||
import { readFileSync } from 'fs' | ||
import { readFileSync, existsSync } from 'fs' | ||
import { z } from 'zod' | ||
|
||
export const configSchema = z.object({ | ||
routeFilePrefix: z.string().optional(), | ||
routeFileIgnorePrefix: z.string().optional().default('-'), | ||
routesDirectory: z.string(), | ||
generatedRouteTree: z.string(), | ||
routesDirectory: z.string().optional().default('./src/routes'), | ||
generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'), | ||
quoteStyle: z.enum(['single', 'double']).optional().default('single'), | ||
future: z | ||
.object({ | ||
unstable_codeSplitting: z.boolean().optional(), | ||
}) | ||
.optional(), | ||
}) | ||
|
||
export type Config = z.infer<typeof configSchema> | ||
|
||
const configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json') | ||
|
||
export async function getConfig(): Promise<Config> { | ||
return configSchema.parse( | ||
JSON.parse(readFileSync(configFilePathJson, 'utf-8')), | ||
) | ||
const exists = existsSync(configFilePathJson) | ||
|
||
if (exists) { | ||
return configSchema.parse( | ||
JSON.parse(readFileSync(configFilePathJson, 'utf-8')), | ||
) | ||
} | ||
|
||
return configSchema.parse({}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters