(files, fileName)
| 97 | }; |
| 98 | |
| 99 | const importDefault = async (files, fileName) => { |
| 100 | const pJSON = await projectPackageJSON; |
| 101 | // Check first if overrides are manually specified in the project's package.json |
| 102 | if (pJSON && pJSON.browserless && typeof pJSON.browserless === 'object') { |
| 103 | const camelCaseFileName = camelCase(fileName); |
| 104 | const relativePath = pJSON.browserless[camelCaseFileName]; |
| 105 | if (relativePath) { |
| 106 | const fullFilePath = path.join( |
| 107 | compiledDir, |
| 108 | translateSrcToBuild(relativePath), |
| 109 | ); |
| 110 | log(`Importing module from package.json: "${fullFilePath}"`); |
| 111 | return (await import(fullFilePath)).default; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | const classModuleFile = files.find((f) => |
| 116 | path.parse(f).name.endsWith(fileName), |
| 117 | ); |
| 118 | |
| 119 | if (!classModuleFile) { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | const fullFilePath = normalizeFileProtocol( |
| 124 | path.join(compiledDir, classModuleFile), |
| 125 | ); |
| 126 | |
| 127 | if (!classModuleFile) { |
| 128 | return; |
| 129 | } |
| 130 | log(`Importing module from found files: "${fullFilePath}"`); |
| 131 | return (await import(fullFilePath)).default; |
| 132 | }; |
| 133 | |
| 134 | const clean = async () => |
| 135 | fs.rm(path.join(compiledDir), { |
no test coverage detected