nav tabs on admin dashboard
This commit is contained in:
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