Updating NPM dependencies
This commit is contained in:
47
node_modules/resolve/lib/sync.js
generated
vendored
47
node_modules/resolve/lib/sync.js
generated
vendored
@@ -1,9 +1,11 @@
|
||||
var isCore = require('./is-core');
|
||||
var isCore = require('is-core-module');
|
||||
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 caller = require('./caller');
|
||||
var nodeModulesPaths = require('./node-modules-paths');
|
||||
var normalizeOptions = require('./normalize-options');
|
||||
|
||||
var realpathFS = fs.realpathSync && typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync;
|
||||
|
||||
var defaultIsFile = function isFile(file) {
|
||||
try {
|
||||
@@ -25,19 +27,24 @@ var defaultIsDir = function isDirectory(dir) {
|
||||
return stat.isDirectory();
|
||||
};
|
||||
|
||||
var maybeUnwrapSymlink = function maybeUnwrapSymlink(x, opts) {
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
try {
|
||||
return fs.realpathSync(x);
|
||||
} catch (realPathErr) {
|
||||
if (realPathErr.code !== 'ENOENT') {
|
||||
throw realPathErr;
|
||||
}
|
||||
var defaultRealpathSync = function realpathSync(x) {
|
||||
try {
|
||||
return realpathFS(x);
|
||||
} catch (realpathErr) {
|
||||
if (realpathErr.code !== 'ENOENT') {
|
||||
throw realpathErr;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
};
|
||||
|
||||
var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
return realpathSync(x);
|
||||
}
|
||||
return x;
|
||||
};
|
||||
|
||||
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
||||
var dirs = nodeModulesPaths(start, opts, x);
|
||||
for (var i = 0; i < dirs.length; i++) {
|
||||
@@ -55,27 +62,29 @@ module.exports = function resolveSync(x, options) {
|
||||
var isFile = opts.isFile || defaultIsFile;
|
||||
var readFileSync = opts.readFileSync || fs.readFileSync;
|
||||
var isDirectory = opts.isDirectory || defaultIsDir;
|
||||
var realpathSync = opts.realpathSync || defaultRealpathSync;
|
||||
var packageIterator = opts.packageIterator;
|
||||
|
||||
var extensions = opts.extensions || ['.js'];
|
||||
var includeCoreModules = opts.includeCoreModules !== false;
|
||||
var basedir = opts.basedir || path.dirname(caller());
|
||||
var parent = opts.filename || basedir;
|
||||
|
||||
opts.paths = opts.paths || [];
|
||||
|
||||
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
||||
var absoluteStart = maybeUnwrapSymlink(path.resolve(basedir), opts);
|
||||
var absoluteStart = maybeRealpathSync(realpathSync, path.resolve(basedir), opts);
|
||||
|
||||
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
||||
var res = path.resolve(absoluteStart, x);
|
||||
if (x === '..' || x.slice(-1) === '/') res += '/';
|
||||
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
||||
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
||||
if (m) return maybeUnwrapSymlink(m, opts);
|
||||
} else if (isCore(x)) {
|
||||
if (m) return maybeRealpathSync(realpathSync, m, opts);
|
||||
} else if (includeCoreModules && isCore(x)) {
|
||||
return x;
|
||||
} else {
|
||||
var n = loadNodeModulesSync(x, absoluteStart);
|
||||
if (n) return maybeUnwrapSymlink(n, opts);
|
||||
if (n) return maybeRealpathSync(realpathSync, n, opts);
|
||||
}
|
||||
|
||||
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
||||
@@ -112,7 +121,7 @@ module.exports = function resolveSync(x, options) {
|
||||
}
|
||||
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
|
||||
|
||||
var pkgfile = path.join(maybeUnwrapSymlink(dir, opts), 'package.json');
|
||||
var pkgfile = path.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json');
|
||||
|
||||
if (!isFile(pkgfile)) {
|
||||
return loadpkg(path.dirname(dir));
|
||||
@@ -133,7 +142,7 @@ module.exports = function resolveSync(x, options) {
|
||||
}
|
||||
|
||||
function loadAsDirectorySync(x) {
|
||||
var pkgfile = path.join(maybeUnwrapSymlink(x, opts), '/package.json');
|
||||
var pkgfile = path.join(maybeRealpathSync(realpathSync, x, opts), '/package.json');
|
||||
if (isFile(pkgfile)) {
|
||||
try {
|
||||
var body = readFileSync(pkgfile, 'UTF8');
|
||||
|
||||
Reference in New Issue
Block a user