* Returns the relative path from the to the targeted folder. * @param {string} originalPath * @param {string} targetFolderPath * @param {string} testsPath
(originalPath, targetFolderPath, testsPath)
| 200 | * @param {string} testsPath |
| 201 | */ |
| 202 | function getPath(originalPath, targetFolderPath, testsPath) { |
| 203 | const parsedPath = path.parse(originalPath) |
| 204 | |
| 205 | // Remove typescript extension if exists. |
| 206 | if (parsedPath.base.endsWith('.d.ts')) parsedPath.base = parsedPath.base.substring(0, parsedPath.base.length - 5) |
| 207 | else if (parsedPath.ext === '.ts') parsedPath.base = parsedPath.name |
| 208 | |
| 209 | if (!parsedPath.dir.startsWith('.')) return path.posix.join(parsedPath.dir, parsedPath.base) |
| 210 | const relativePath = path.posix.relative( |
| 211 | targetFolderPath.split(path.sep).join(path.posix.sep), |
| 212 | path.posix.join(testsPath.split(path.sep).join(path.posix.sep), parsedPath.dir.split(path.sep).join(path.posix.sep), parsedPath.base.split(path.sep).join(path.posix.sep)), |
| 213 | ) |
| 214 | |
| 215 | return relativePath.startsWith('.') ? relativePath : `./${relativePath}` |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * |