This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+18
View File
@@ -0,0 +1,18 @@
"use strict";
var fs = require("fs");
module.exports = function (cache) {
cache = cache || {};
return function (filename) {
if (!filename) {
return false;
}
cache[filename] = cache[filename] || fs.existsSync(filename);
return cache[filename];
};
};
+18
View File
@@ -0,0 +1,18 @@
"use strict";
var fs = require("fs");
module.exports = function (cache) {
cache = cache || {};
return function (filename) {
if (!filename) {
throw new Error("filename must be a string");
}
cache[filename] = cache[filename] || fs.readFileSync(filename, "utf8");
return cache[filename];
};
};
+14
View File
@@ -0,0 +1,14 @@
"use strict";
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);
};