Skip to content

Commit f629709

Browse files
authored
fix: increase safety of findConfig (#10400)
If `@payload-config` is not set in tsconfig, findConfig could fail when performing a `path.extname` on an undefined value. Example error in this scenario: ``` TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined. ```
1 parent d772b2b commit f629709

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/payload/src/config/find.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const findConfig = (): string => {
6767
const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths()
6868

6969
// if configPath is absolute file, not folder, return it
70-
if (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts') {
70+
if (configPath && (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts')) {
7171
return configPath
7272
}
7373

0 commit comments

Comments
 (0)