nav tabs on admin dashboard
This commit is contained in:
63
node_modules/resolve/lib/async.js
generated
vendored
63
node_modules/resolve/lib/async.js
generated
vendored
@@ -3,6 +3,7 @@ var fs = require('fs');
|
||||
var path = require('path');
|
||||
var caller = require('./caller.js');
|
||||
var nodeModulesPaths = require('./node-modules-paths.js');
|
||||
var normalizeOptions = require('./normalize-options.js');
|
||||
|
||||
var defaultIsFile = function isFile(file, cb) {
|
||||
fs.stat(file, function (err, stat) {
|
||||
@@ -16,8 +17,8 @@ var defaultIsFile = function isFile(file, cb) {
|
||||
|
||||
module.exports = function resolve(x, options, callback) {
|
||||
var cb = callback;
|
||||
var opts = options || {};
|
||||
if (typeof opts === 'function') {
|
||||
var opts = options;
|
||||
if (typeof options === 'function') {
|
||||
cb = opts;
|
||||
opts = {};
|
||||
}
|
||||
@@ -28,6 +29,8 @@ module.exports = function resolve(x, options, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
opts = normalizeOptions(x, opts);
|
||||
|
||||
var isFile = opts.isFile || defaultIsFile;
|
||||
var readFile = opts.readFile || fs.readFile;
|
||||
|
||||
@@ -37,22 +40,37 @@ module.exports = function resolve(x, options, callback) {
|
||||
|
||||
opts.paths = opts.paths || [];
|
||||
|
||||
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
|
||||
var res = path.resolve(basedir, x);
|
||||
if (x === '..' || x.slice(-1) === '/') res += '/';
|
||||
if (/\/$/.test(x) && res === basedir) {
|
||||
loadAsDirectory(res, opts.package, onfile);
|
||||
} else loadAsFile(res, opts.package, onfile);
|
||||
} else loadNodeModules(x, basedir, function (err, n, pkg) {
|
||||
if (err) cb(err);
|
||||
else if (n) cb(null, n, pkg);
|
||||
else if (core[x]) return cb(null, x);
|
||||
else {
|
||||
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
moduleError.code = 'MODULE_NOT_FOUND';
|
||||
cb(moduleError);
|
||||
}
|
||||
});
|
||||
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
||||
var absoluteStart = path.resolve(basedir);
|
||||
|
||||
if (opts.preserveSymlinks === false) {
|
||||
fs.realpath(absoluteStart, function (realPathErr, realStart) {
|
||||
if (realPathErr && realPathErr.code !== 'ENOENT') cb(err);
|
||||
else init(realPathErr ? absoluteStart : realStart);
|
||||
});
|
||||
} else {
|
||||
init(absoluteStart);
|
||||
}
|
||||
|
||||
var res;
|
||||
function init(basedir) {
|
||||
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
||||
res = path.resolve(basedir, x);
|
||||
if (x === '..' || x.slice(-1) === '/') res += '/';
|
||||
if ((/\/$/).test(x) && res === basedir) {
|
||||
loadAsDirectory(res, opts.package, onfile);
|
||||
} else loadAsFile(res, opts.package, onfile);
|
||||
} else loadNodeModules(x, basedir, function (err, n, pkg) {
|
||||
if (err) cb(err);
|
||||
else if (n) cb(null, n, pkg);
|
||||
else if (core[x]) return cb(null, x);
|
||||
else {
|
||||
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
moduleError.code = 'MODULE_NOT_FOUND';
|
||||
cb(moduleError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onfile(err, m, pkg) {
|
||||
if (err) cb(err);
|
||||
@@ -115,7 +133,7 @@ module.exports = function resolve(x, options, callback) {
|
||||
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
||||
return cb(null);
|
||||
}
|
||||
if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
|
||||
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);
|
||||
|
||||
var pkgfile = path.join(dir, 'package.json');
|
||||
isFile(pkgfile, function (err, ex) {
|
||||
@@ -158,6 +176,11 @@ module.exports = function resolve(x, options, callback) {
|
||||
}
|
||||
|
||||
if (pkg.main) {
|
||||
if (typeof pkg.main !== 'string') {
|
||||
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
||||
mainError.code = 'INVALID_PACKAGE_MAIN';
|
||||
return cb(mainError);
|
||||
}
|
||||
if (pkg.main === '.' || pkg.main === './') {
|
||||
pkg.main = 'index';
|
||||
}
|
||||
@@ -201,6 +224,6 @@ module.exports = function resolve(x, options, callback) {
|
||||
}
|
||||
}
|
||||
function loadNodeModules(x, start, cb) {
|
||||
processDirs(cb, nodeModulesPaths(start, opts));
|
||||
processDirs(cb, nodeModulesPaths(start, opts, x));
|
||||
}
|
||||
};
|
||||
|
||||
1
node_modules/resolve/lib/core.json
generated
vendored
1
node_modules/resolve/lib/core.json
generated
vendored
@@ -68,5 +68,6 @@
|
||||
"v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0"],
|
||||
"v8": ">= 1",
|
||||
"vm": true,
|
||||
"worker_threads": ">= 11.7",
|
||||
"zlib": true
|
||||
}
|
||||
|
||||
43
node_modules/resolve/lib/node-modules-paths.js
generated
vendored
43
node_modules/resolve/lib/node-modules-paths.js
generated
vendored
@@ -1,30 +1,11 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var parse = path.parse || require('path-parse');
|
||||
|
||||
module.exports = function nodeModulesPaths(start, opts) {
|
||||
var modules = opts && opts.moduleDirectory
|
||||
? [].concat(opts.moduleDirectory)
|
||||
: ['node_modules'];
|
||||
|
||||
// ensure that `start` is an absolute path at this point,
|
||||
// resolving against the process' current working directory
|
||||
var absoluteStart = path.resolve(start);
|
||||
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
try {
|
||||
absoluteStart = fs.realpathSync(absoluteStart);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
|
||||
var prefix = '/';
|
||||
if (/^([A-Za-z]:)/.test(absoluteStart)) {
|
||||
if ((/^([A-Za-z]:)/).test(absoluteStart)) {
|
||||
prefix = '';
|
||||
} else if (/^\\\\/.test(absoluteStart)) {
|
||||
} else if ((/^\\\\/).test(absoluteStart)) {
|
||||
prefix = '\\\\';
|
||||
}
|
||||
|
||||
@@ -35,11 +16,27 @@ module.exports = function nodeModulesPaths(start, opts) {
|
||||
parsed = parse(parsed.dir);
|
||||
}
|
||||
|
||||
var dirs = paths.reduce(function (dirs, aPath) {
|
||||
return paths.reduce(function (dirs, aPath) {
|
||||
return dirs.concat(modules.map(function (moduleDir) {
|
||||
return path.join(prefix, aPath, moduleDir);
|
||||
}));
|
||||
}, []);
|
||||
};
|
||||
|
||||
module.exports = function nodeModulesPaths(start, opts, request) {
|
||||
var modules = opts && opts.moduleDirectory
|
||||
? [].concat(opts.moduleDirectory)
|
||||
: ['node_modules'];
|
||||
|
||||
if (opts && typeof opts.paths === 'function') {
|
||||
return opts.paths(
|
||||
request,
|
||||
start,
|
||||
function () { return getNodeModulesDirs(start, modules); },
|
||||
opts
|
||||
);
|
||||
}
|
||||
|
||||
var dirs = getNodeModulesDirs(start, modules);
|
||||
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
|
||||
};
|
||||
|
||||
52
node_modules/resolve/lib/sync.js
generated
vendored
52
node_modules/resolve/lib/sync.js
generated
vendored
@@ -3,6 +3,7 @@ var fs = require('fs');
|
||||
var path = require('path');
|
||||
var caller = require('./caller.js');
|
||||
var nodeModulesPaths = require('./node-modules-paths.js');
|
||||
var normalizeOptions = require('./normalize-options.js');
|
||||
|
||||
var defaultIsFile = function isFile(file) {
|
||||
try {
|
||||
@@ -18,7 +19,8 @@ module.exports = function (x, options) {
|
||||
if (typeof x !== 'string') {
|
||||
throw new TypeError('Path must be a string.');
|
||||
}
|
||||
var opts = options || {};
|
||||
var opts = normalizeOptions(x, options);
|
||||
|
||||
var isFile = opts.isFile || defaultIsFile;
|
||||
var readFileSync = opts.readFileSync || fs.readFileSync;
|
||||
|
||||
@@ -28,13 +30,26 @@ module.exports = function (x, options) {
|
||||
|
||||
opts.paths = opts.paths || [];
|
||||
|
||||
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
|
||||
var res = path.resolve(basedir, x);
|
||||
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
||||
var absoluteStart = path.resolve(basedir);
|
||||
|
||||
if (opts.preserveSymlinks === false) {
|
||||
try {
|
||||
absoluteStart = fs.realpathSync(absoluteStart);
|
||||
} catch (realPathErr) {
|
||||
if (realPathErr.code !== 'ENOENT') {
|
||||
throw realPathErr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
||||
var res = path.resolve(absoluteStart, x);
|
||||
if (x === '..' || x.slice(-1) === '/') res += '/';
|
||||
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
||||
if (m) return m;
|
||||
} else {
|
||||
var n = loadNodeModulesSync(x, basedir);
|
||||
var n = loadNodeModulesSync(x, absoluteStart);
|
||||
if (n) return n;
|
||||
}
|
||||
|
||||
@@ -72,7 +87,7 @@ module.exports = function (x, options) {
|
||||
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
||||
return;
|
||||
}
|
||||
if (/[/\\]node_modules[/\\]*$/.test(dir)) return;
|
||||
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
|
||||
|
||||
var pkgfile = path.join(dir, 'package.json');
|
||||
|
||||
@@ -99,28 +114,35 @@ module.exports = function (x, options) {
|
||||
try {
|
||||
var body = readFileSync(pkgfile, 'UTF8');
|
||||
var pkg = JSON.parse(body);
|
||||
} catch (e) {}
|
||||
|
||||
if (opts.packageFilter) {
|
||||
pkg = opts.packageFilter(pkg, x);
|
||||
if (opts.packageFilter) {
|
||||
pkg = opts.packageFilter(pkg, x);
|
||||
}
|
||||
|
||||
if (pkg.main) {
|
||||
if (typeof pkg.main !== 'string') {
|
||||
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
||||
mainError.code = 'INVALID_PACKAGE_MAIN';
|
||||
throw mainError;
|
||||
}
|
||||
|
||||
if (pkg.main) {
|
||||
if (pkg.main === '.' || pkg.main === './') {
|
||||
pkg.main = 'index';
|
||||
}
|
||||
if (pkg.main === '.' || pkg.main === './') {
|
||||
pkg.main = 'index';
|
||||
}
|
||||
try {
|
||||
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
||||
if (m) return m;
|
||||
var n = loadAsDirectorySync(path.resolve(x, pkg.main));
|
||||
if (n) return n;
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return loadAsFileSync(path.join(x, '/index'));
|
||||
}
|
||||
|
||||
function loadNodeModulesSync(x, start) {
|
||||
var dirs = nodeModulesPaths(start, opts);
|
||||
var dirs = nodeModulesPaths(start, opts, x);
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
var dir = dirs[i];
|
||||
var m = loadAsFileSync(path.join(dir, '/', x));
|
||||
|
||||
Reference in New Issue
Block a user