MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / getPath

Function getPath

lib/command/definitions.js:202–216  ·  view source on GitHub ↗

* Returns the relative path from the to the targeted folder. * @param {string} originalPath * @param {string} targetFolderPath * @param {string} testsPath

(originalPath, targetFolderPath, testsPath)

Source from the content-addressed store, hash-verified

200 * @param {string} testsPath
201 */
202function 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 *

Callers 1

getImportStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected