relative.js 353 B

1234567891011121314
  1. "use strict";
  2. var path = require("path");
  3. module.exports = function relative(sourceRoot, filename) {
  4. var rootPath = sourceRoot.replace(/\\/g, "/").split("/")[1];
  5. var fileRootPath = filename.replace(/\\/g, "/").split("/")[1];
  6. if (rootPath && rootPath !== fileRootPath) {
  7. return filename;
  8. }
  9. return path.relative(sourceRoot, filename);
  10. };