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));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user