forked from github.com/GenderDysphoria.fyi
Burn it down and rise from the ashes
This commit is contained in:
26
gulp/content/resolve.js
Normal file
26
gulp/content/resolve.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
const path = require('path');
|
||||
const ROOT = path.resolve(__dirname, '../..');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
exports.readFile = function readFile (fpath) {
|
||||
fpath = exports.resolve(fpath);
|
||||
return fs.readFile(fpath).catch((err) => {
|
||||
throw new Error(err.trace);
|
||||
});
|
||||
};
|
||||
|
||||
exports.resolve = function resolve (...args) {
|
||||
args = args.filter(Boolean);
|
||||
let fpath = args.shift();
|
||||
if (!fpath) return ROOT;
|
||||
if (fpath[0] === '/') throw new Error('Did you mean to resolve this? ' + fpath);
|
||||
if (fpath[0] === '/') fpath = fpath.slice(1);
|
||||
return path.resolve(ROOT, fpath, ...args);
|
||||
};
|
||||
|
||||
exports.relative = function relative (fpath) {
|
||||
return path.relative(ROOT, fpath);
|
||||
};
|
||||
|
||||
exports.ROOT = ROOT;
|
||||
Reference in New Issue
Block a user