MCPcopy
hub / github.com/webpack/webpack / relative

Function relative

lib/util/fs.js:539–550  ·  view source on GitHub ↗
(fs, rootPath, targetPath)

Source from the content-addressed store, hash-verified

537 * @returns {string} location of targetPath relative to rootPath
538 */
539const relative = (fs, rootPath, targetPath) => {
540 if (fs && fs.relative) {
541 return fs.relative(rootPath, targetPath);
542 } else if (path.posix.isAbsolute(rootPath)) {
543 return path.posix.relative(rootPath, targetPath);
544 } else if (path.win32.isAbsolute(rootPath)) {
545 return path.win32.relative(rootPath, targetPath);
546 }
547 throw new Error(
548 `${rootPath} is neither a posix nor a windows path, and there is no 'relative' method defined in the file system`
549 );
550};
551
552/**
553 * Returns the joined path.

Callers 3

applyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected