(
from: string,
moduleName: string | undefined,
)
| 170 | } |
| 171 | |
| 172 | private resolvePaths( |
| 173 | from: string, |
| 174 | moduleName: string | undefined, |
| 175 | ): Array<string> | null { |
| 176 | const fromDir = path.resolve(from, '..'); |
| 177 | if (moduleName == null) { |
| 178 | throw new Error( |
| 179 | 'The first argument to require.resolve.paths must be a string. Received null or undefined.', |
| 180 | ); |
| 181 | } |
| 182 | if (moduleName.length === 0) { |
| 183 | throw new Error( |
| 184 | 'The first argument to require.resolve.paths must not be the empty string.', |
| 185 | ); |
| 186 | } |
| 187 | |
| 188 | if (moduleName[0] === '.') { |
| 189 | return [fromDir]; |
| 190 | } |
| 191 | if (this.resolution.isCoreModule(moduleName)) { |
| 192 | return null; |
| 193 | } |
| 194 | const modulePaths = this.resolution.getModulePaths(fromDir); |
| 195 | const globalPaths = this.resolution.getGlobalPaths(moduleName); |
| 196 | return [...modulePaths, ...globalPaths]; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | export interface CoreModuleProviderOptions { |
no test coverage detected