| 28 | new ValidationError(`${BULLET}Validation Error`, message, DOCUMENTATION_NOTE); |
| 29 | |
| 30 | export const resolve = ( |
| 31 | resolver: string | null | undefined, |
| 32 | {key, filePath, rootDir, optional}: ResolveOptions, |
| 33 | ): string => { |
| 34 | const module = Resolver.findNodeModule( |
| 35 | replaceRootDirInPath(rootDir, filePath), |
| 36 | { |
| 37 | basedir: rootDir, |
| 38 | resolver: resolver || undefined, |
| 39 | }, |
| 40 | ); |
| 41 | |
| 42 | if (!module && !optional) { |
| 43 | throw createValidationError( |
| 44 | ` Module ${chalk.bold(filePath)} in the ${chalk.bold( |
| 45 | key, |
| 46 | )} option was not found. |
| 47 | ${chalk.bold('<rootDir>')} is: ${rootDir}`, |
| 48 | ); |
| 49 | } |
| 50 | /// can cast as string since nulls will be thrown |
| 51 | return module!; |
| 52 | }; |
| 53 | |
| 54 | export const escapeGlobCharacters = (path: string): string => |
| 55 | path.replaceAll(/([!()*?[\\\]{}])/g, '\\$1'); |