json-q
Version:
Retrieves values from JSON objects (and JavaScript objects) by css-selector-like query (includes attribute filters and array flattening).
14 lines (10 loc) • 353 B
JavaScript
var path = require("path");
module.exports = function relative(sourceRoot, filename) {
var rootPath = sourceRoot.replace(/\\/g, "/").split("/")[1];
var fileRootPath = filename.replace(/\\/g, "/").split("/")[1];
if (rootPath && rootPath !== fileRootPath) {
return filename;
}
return path.relative(sourceRoot, filename);
};
;