nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

2
node_modules/resolve/.editorconfig generated vendored
View File

@@ -7,7 +7,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
max_line_length = 150
[CHANGELOG.md]
indent_style = space

1
node_modules/resolve/.eslintrc generated vendored
View File

@@ -14,6 +14,7 @@
"func-style": 0,
"global-require": 0,
"id-length": [2, { "min": 1, "max": 30 }],
"max-lines-per-function": 0,
"max-nested-callbacks": 0,
"max-params": 0,
"max-statements-per-line": [2, { "max": 2 }],

56
node_modules/resolve/.travis.yml generated vendored
View File

@@ -2,11 +2,12 @@ language: node_js
os:
- linux
node_js:
- "10.4"
- "11.6"
- "10.15"
- "9.11"
- "8.11"
- "8.15"
- "7.10"
- "6.14"
- "6.16"
- "5.12"
- "4.9"
- "iojs-v3.3"
@@ -34,6 +35,42 @@ matrix:
include:
- node_js: "lts/*"
env: PRETEST=true
- node_js: "lts/*"
env: POSTTEST=true
- node_js: "11.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.14"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.13"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.12"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.2"
@@ -64,6 +101,14 @@ matrix:
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.14"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.13"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.12"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.9"
@@ -106,6 +151,10 @@ matrix:
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.15"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.14"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.13"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.12"
@@ -217,3 +266,4 @@ matrix:
allow_failures:
- os: osx
- env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"

63
node_modules/resolve/lib/async.js generated vendored
View File

@@ -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
View File

@@ -68,5 +68,6 @@
"v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8": ">= 1",
"vm": true,
"worker_threads": ">= 11.7",
"zlib": true
}

View File

@@ -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
View File

@@ -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));

39
node_modules/resolve/package.json generated vendored
View File

@@ -1,27 +1,28 @@
{
"_from": "resolve@^1.4.0",
"_id": "resolve@1.8.1",
"_from": "resolve@^1.3.2",
"_id": "resolve@1.10.0",
"_inBundle": false,
"_integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
"_integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
"_location": "/resolve",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "resolve@^1.4.0",
"raw": "resolve@^1.3.2",
"name": "resolve",
"escapedName": "resolve",
"rawSpec": "^1.4.0",
"rawSpec": "^1.3.2",
"saveSpec": null,
"fetchSpec": "^1.4.0"
"fetchSpec": "^1.3.2"
},
"_requiredBy": [
"/vue-loader"
"/@babel/core",
"/@babel/plugin-transform-runtime"
],
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
"_shasum": "82f1ec19a423ac1fbd080b0bab06ba36e84a7a26",
"_spec": "resolve@^1.4.0",
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\vue-loader",
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz",
"_shasum": "3bdaaeaf45cc07f375656dfd2e54ed0810b101ba",
"_spec": "resolve@^1.3.2",
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\@babel\\core",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
@@ -32,17 +33,17 @@
},
"bundleDependencies": false,
"dependencies": {
"path-parse": "^1.0.5"
"path-parse": "^1.0.6"
},
"deprecated": false,
"description": "resolve like require.resolve() on behalf of files asynchronously and synchronously",
"devDependencies": {
"@ljharb/eslint-config": "^12.2.1",
"eslint": "^4.19.1",
"object-keys": "^1.0.11",
"safe-publish-latest": "^1.1.1",
"@ljharb/eslint-config": "^13.1.1",
"eslint": "^5.12.0",
"object-keys": "^1.0.12",
"safe-publish-latest": "^1.1.2",
"tap": "0.4.13",
"tape": "^4.9.0"
"tape": "^4.9.2"
},
"homepage": "https://github.com/browserify/resolve#readme",
"keywords": [
@@ -60,10 +61,12 @@
},
"scripts": {
"lint": "eslint .",
"posttest": "npm run test:multirepo",
"prepublish": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run --silent tests-only",
"test:multirepo": "cd ./test/resolver/multirepo && npm install && npm test",
"tests-only": "tape test/*.js"
},
"version": "1.8.1"
"version": "1.10.0"
}

View File

@@ -71,6 +71,12 @@ options are:
* opts.paths - require.paths array to use if nothing is found on the normal `node_modules` recursive walk (probably don't use this)
For advanced users, `paths` can also be a `opts.paths(request, start, opts)` function
* request - the import specifier being resolved
* start - lookup path
* getNodeModulesDirs - a thunk (no-argument function) that returns the paths using standard `node_modules` resolution
* opts - the resolution options
* opts.moduleDirectory - directory (or directories) in which to recursively look for modules. default: `"node_modules"`
* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.

View File

@@ -1,4 +1,5 @@
var test = require('tape');
var path = require('path');
var resolve = require('../');
test('faulty basedir must produce error in windows', { skip: process.platform !== 'win32' }, function (t) {
@@ -7,7 +8,22 @@ test('faulty basedir must produce error in windows', { skip: process.platform !=
var resolverDir = 'C:\\a\\b\\c\\d';
resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) {
t.equal(true, !!err);
t.equal(!!err, true);
});
});
test('non-existent basedir should not throw when preserveSymlinks is false', function (t) {
t.plan(2);
var opts = {
basedir: path.join(path.sep, 'unreal', 'path', 'that', 'does', 'not', 'exist'),
preserveSymlinks: false
};
var module = './dotdot/abc';
resolve(module, opts, function (err, res) {
t.equal(err.code, 'MODULE_NOT_FOUND');
t.equal(res, undefined);
});
});

View File

@@ -7,6 +7,11 @@ var nodeModulesPaths = require('../lib/node-modules-paths');
var verifyDirs = function verifyDirs(t, start, dirs, moduleDirectories, paths) {
var moduleDirs = [].concat(moduleDirectories || 'node_modules');
if (paths) {
for (var k = 0; k < paths.length; ++k) {
moduleDirs.push(path.basename(paths[k]));
}
}
var foundModuleDirs = {};
var uniqueDirs = {};
@@ -20,7 +25,7 @@ var verifyDirs = function verifyDirs(t, start, dirs, moduleDirectories, paths) {
}
t.equal(keys(parsedDirs).length >= start.split(path.sep).length, true, 'there are >= dirs than "start" has');
var foundModuleDirNames = keys(foundModuleDirs);
t.deepEqual(foundModuleDirNames, moduleDirs.concat(paths || []), 'all desired module dirs were found');
t.deepEqual(foundModuleDirNames, moduleDirs, 'all desired module dirs were found');
t.equal(keys(uniqueDirs).length, dirs.length, 'all dirs provided were unique');
var counts = {};
@@ -49,7 +54,7 @@ test('node-modules-paths', function (t) {
t.end();
});
t.test('with paths option', function (t) {
t.test('with paths=array option', function (t) {
var start = path.join(__dirname, 'resolver');
var paths = ['a', 'b'];
var dirs = nodeModulesPaths(start, { paths: paths });
@@ -59,6 +64,29 @@ test('node-modules-paths', function (t) {
t.end();
});
t.test('with paths=function option', function (t) {
var paths = function paths(request, absoluteStart, getNodeModulesDirs, opts) {
return getNodeModulesDirs().concat(path.join(absoluteStart, 'not node modules', request));
};
var start = path.join(__dirname, 'resolver');
var dirs = nodeModulesPaths(start, { paths: paths }, 'pkg');
verifyDirs(t, start, dirs, null, [path.join(start, 'not node modules', 'pkg')]);
t.end();
});
t.test('with paths=function skipping node modules resolution', function (t) {
var paths = function paths(request, absoluteStart, getNodeModulesDirs, opts) {
return [];
};
var start = path.join(__dirname, 'resolver');
var dirs = nodeModulesPaths(start, { paths: paths });
t.deepEqual(dirs, [], 'no node_modules was computed');
t.end();
});
t.test('with moduleDirectory option', function (t) {
var start = path.join(__dirname, 'resolver');
var moduleDirectory = 'not node modules';

View File

@@ -1,18 +1,34 @@
var fs = require('fs');
var path = require('path');
var test = require('tape');
var resolve = require('../');
test('$NODE_PATH', function (t) {
t.plan(4);
t.plan(8);
var isDir = function (dir, cb) {
if (dir === '/node_path' || dir === 'node_path/x') {
return cb(null, true);
}
fs.stat(dir, function (err, stat) {
if (!err) {
return cb(null, stat.isDirectory());
}
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
return cb(err);
});
};
resolve('aaa', {
paths: [
path.join(__dirname, '/node_path/x'),
path.join(__dirname, '/node_path/y')
],
basedir: __dirname
basedir: __dirname,
isDirectory: isDir
}, function (err, res) {
t.equal(res, path.join(__dirname, '/node_path/x/aaa/index.js'));
t.error(err);
t.equal(res, path.join(__dirname, '/node_path/x/aaa/index.js'), 'aaa resolves');
});
resolve('bbb', {
@@ -20,9 +36,11 @@ test('$NODE_PATH', function (t) {
path.join(__dirname, '/node_path/x'),
path.join(__dirname, '/node_path/y')
],
basedir: __dirname
basedir: __dirname,
isDirectory: isDir
}, function (err, res) {
t.equal(res, path.join(__dirname, '/node_path/y/bbb/index.js'));
t.error(err);
t.equal(res, path.join(__dirname, '/node_path/y/bbb/index.js'), 'bbb resolves');
});
resolve('ccc', {
@@ -30,20 +48,23 @@ test('$NODE_PATH', function (t) {
path.join(__dirname, '/node_path/x'),
path.join(__dirname, '/node_path/y')
],
basedir: __dirname
basedir: __dirname,
isDirectory: isDir
}, function (err, res) {
t.equal(res, path.join(__dirname, '/node_path/x/ccc/index.js'));
t.error(err);
t.equal(res, path.join(__dirname, '/node_path/x/ccc/index.js'), 'ccc resolves');
});
// ensure that relative paths still resolve against the
// regular `node_modules` correctly
// ensure that relative paths still resolve against the regular `node_modules` correctly
resolve('tap', {
paths: [
'node_path'
],
basedir: 'node_path/x'
basedir: path.join(__dirname, 'node_path/x'),
isDirectory: isDir
}, function (err, res) {
var root = require('tap/package.json').main;
t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap', root));
t.error(err);
t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap', root), 'tap resolves');
});
});

View File

@@ -364,7 +364,7 @@ test('async dot slash main', function (t) {
});
test('not a directory', function (t) {
t.plan(5);
t.plan(6);
var path = './foo';
resolve(path, { basedir: __filename }, function (err, res, pkg) {
t.ok(err, 'a non-directory errors');
@@ -372,7 +372,34 @@ test('not a directory', function (t) {
t.equal(res, undefined);
t.equal(pkg, undefined);
t.equal(err && err.message, 'Cannot find module \'' + path + "' from '" + __filename + "'");
t.equal(err && err.message, 'Cannot find module \'' + path + '\' from \'' + __filename + '\'');
t.equal(err && err.code, 'MODULE_NOT_FOUND');
});
});
test('non-string "main" field in package.json', function (t) {
t.plan(5);
var dir = path.join(__dirname, 'resolver');
resolve('./invalid_main', { basedir: dir }, function (err, res, pkg) {
t.ok(err, 'errors on non-string main');
t.equal(err.message, 'package “invalid main” `main` must be a string');
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
t.equal(res, undefined, 'res is undefined');
t.equal(pkg, undefined, 'pkg is undefined');
});
});
test('non-string "main" field in package.json', function (t) {
t.plan(5);
var dir = path.join(__dirname, 'resolver');
resolve('./invalid_main', { basedir: dir }, function (err, res, pkg) {
t.ok(err, 'errors on non-string main');
t.equal(err.message, 'package “invalid main” `main` must be a string');
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
t.equal(res, undefined, 'res is undefined');
t.equal(pkg, undefined, 'pkg is undefined');
});
});

View File

@@ -290,6 +290,35 @@ test('not a directory', function (t) {
} catch (err) {
t.ok(err, 'a non-directory errors');
t.equal(err && err.message, 'Cannot find module \'' + path + "' from '" + __filename + "'");
t.equal(err && err.code, 'MODULE_NOT_FOUND');
}
t.end();
});
test('non-string "main" field in package.json', function (t) {
var dir = path.join(__dirname, 'resolver');
try {
var result = resolve.sync('./invalid_main', { basedir: dir });
t.equal(result, undefined, 'result should not exist');
t.fail('should not get here');
} catch (err) {
t.ok(err, 'errors on non-string main');
t.equal(err.message, 'package “invalid main” `main` must be a string');
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
}
t.end();
});
test('non-string "main" field in package.json', function (t) {
var dir = path.join(__dirname, 'resolver');
try {
var result = resolve.sync('./invalid_main', { basedir: dir });
t.equal(result, undefined, 'result should not exist');
t.fail('should not get here');
} catch (err) {
t.ok(err, 'errors on non-string main');
t.equal(err.message, 'package “invalid main” `main` must be a string');
t.equal(err.code, 'INVALID_PACKAGE_MAIN');
}
t.end();
});

View File

@@ -15,10 +15,10 @@ try {
}
test('symlink', function (t) {
t.plan(1);
t.plan(2);
resolve('foo', { basedir: symlinkDir, preserveSymlinks: false }, function (err, res, pkg) {
if (err) t.fail(err);
t.error(err);
t.equal(res, path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js'));
});
});