Skip to content

Commit

Permalink
fix: increase safety of findConfig (#10400)
Browse files Browse the repository at this point in the history
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.
```
  • Loading branch information
denolfe authored Jan 6, 2025
1 parent d772b2b commit f629709
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/payload/src/config/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const findConfig = (): string => {
const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths()

// if configPath is absolute file, not folder, return it
if (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts') {
if (configPath && (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts')) {
return configPath
}

Expand Down

0 comments on commit f629709

Please sign in to comment.