From 9b0c0344ed1109eaab4dcfade7e33f523ec8ff67 Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 19 Aug 2021 10:29:50 -0700 Subject: [PATCH] chore(deps): prune extraneous deps Not sure why this only happened during publish --- node_modules/path-parse/LICENSE | 21 - node_modules/path-parse/index.js | 75 --- node_modules/path-parse/package.json | 33 -- node_modules/resolve/LICENSE | 21 - node_modules/resolve/SECURITY.md | 3 - node_modules/resolve/appveyor.yml | 74 --- node_modules/resolve/example/async.js | 5 - node_modules/resolve/example/sync.js | 3 - node_modules/resolve/index.js | 6 - node_modules/resolve/lib/async.js | 320 ------------- node_modules/resolve/lib/caller.js | 8 - node_modules/resolve/lib/core.js | 53 --- node_modules/resolve/lib/core.json | 83 ---- node_modules/resolve/lib/is-core.js | 5 - .../resolve/lib/node-modules-paths.js | 42 -- node_modules/resolve/lib/normalize-options.js | 10 - node_modules/resolve/lib/sync.js | 199 -------- node_modules/resolve/package.json | 51 -- node_modules/resolve/readme.markdown | 279 ----------- node_modules/resolve/test/core.js | 81 ---- node_modules/resolve/test/dotdot.js | 29 -- node_modules/resolve/test/dotdot/abc/index.js | 2 - node_modules/resolve/test/dotdot/index.js | 1 - node_modules/resolve/test/faulty_basedir.js | 29 -- node_modules/resolve/test/filter.js | 34 -- node_modules/resolve/test/filter_sync.js | 33 -- node_modules/resolve/test/mock.js | 315 ------------ node_modules/resolve/test/mock_sync.js | 216 --------- node_modules/resolve/test/module_dir.js | 56 --- .../test/module_dir/xmodules/aaa/index.js | 1 - .../test/module_dir/ymodules/aaa/index.js | 1 - .../test/module_dir/zmodules/bbb/main.js | 1 - .../test/module_dir/zmodules/bbb/package.json | 3 - .../resolve/test/node-modules-paths.js | 143 ------ node_modules/resolve/test/node_path.js | 70 --- .../resolve/test/node_path/x/aaa/index.js | 1 - .../resolve/test/node_path/x/ccc/index.js | 1 - .../resolve/test/node_path/y/bbb/index.js | 1 - .../resolve/test/node_path/y/ccc/index.js | 1 - node_modules/resolve/test/nonstring.js | 9 - node_modules/resolve/test/pathfilter.js | 75 --- .../resolve/test/pathfilter/deep_ref/main.js | 0 node_modules/resolve/test/precedence.js | 23 - node_modules/resolve/test/precedence/aaa.js | 1 - .../resolve/test/precedence/aaa/index.js | 1 - .../resolve/test/precedence/aaa/main.js | 1 - node_modules/resolve/test/precedence/bbb.js | 1 - .../resolve/test/precedence/bbb/main.js | 1 - node_modules/resolve/test/resolver.js | 450 ------------------ .../resolve/test/resolver/baz/doom.js | 0 .../resolve/test/resolver/baz/package.json | 4 - .../resolve/test/resolver/baz/quux.js | 1 - .../resolve/test/resolver/browser_field/a.js | 0 .../resolve/test/resolver/browser_field/b.js | 0 .../test/resolver/browser_field/package.json | 5 - node_modules/resolve/test/resolver/cup.coffee | 1 - .../resolve/test/resolver/dot_main/index.js | 1 - .../test/resolver/dot_main/package.json | 3 - .../test/resolver/dot_slash_main/index.js | 1 - .../test/resolver/dot_slash_main/package.json | 3 - node_modules/resolve/test/resolver/foo.js | 1 - .../test/resolver/incorrect_main/index.js | 2 - .../test/resolver/incorrect_main/package.json | 3 - .../test/resolver/invalid_main/package.json | 7 - node_modules/resolve/test/resolver/mug.coffee | 0 node_modules/resolve/test/resolver/mug.js | 0 .../test/resolver/multirepo/lerna.json | 6 - .../test/resolver/multirepo/package.json | 20 - .../multirepo/packages/package-a/index.js | 35 -- .../multirepo/packages/package-a/package.json | 14 - .../multirepo/packages/package-b/index.js | 0 .../multirepo/packages/package-b/package.json | 14 - .../resolver/nested_symlinks/mylib/async.js | 26 - .../nested_symlinks/mylib/package.json | 15 - .../resolver/nested_symlinks/mylib/sync.js | 12 - .../test/resolver/other_path/lib/other-lib.js | 0 .../resolve/test/resolver/other_path/root.js | 0 .../resolve/test/resolver/quux/foo/index.js | 1 - .../resolve/test/resolver/same_names/foo.js | 1 - .../test/resolver/same_names/foo/index.js | 1 - .../resolver/symlinked/_/node_modules/foo.js | 0 .../test/resolver/symlinked/package/bar.js | 1 - .../resolver/symlinked/package/package.json | 3 - .../test/resolver/without_basedir/main.js | 5 - node_modules/resolve/test/resolver_sync.js | 358 -------------- node_modules/resolve/test/shadowed_core.js | 54 --- .../shadowed_core/node_modules/util/index.js | 0 node_modules/resolve/test/subdirs.js | 13 - node_modules/resolve/test/symlinks.js | 176 ------- 89 files changed, 3659 deletions(-) delete mode 100644 node_modules/path-parse/LICENSE delete mode 100644 node_modules/path-parse/index.js delete mode 100644 node_modules/path-parse/package.json delete mode 100644 node_modules/resolve/LICENSE delete mode 100644 node_modules/resolve/SECURITY.md delete mode 100644 node_modules/resolve/appveyor.yml delete mode 100644 node_modules/resolve/example/async.js delete mode 100644 node_modules/resolve/example/sync.js delete mode 100644 node_modules/resolve/index.js delete mode 100644 node_modules/resolve/lib/async.js delete mode 100644 node_modules/resolve/lib/caller.js delete mode 100644 node_modules/resolve/lib/core.js delete mode 100644 node_modules/resolve/lib/core.json delete mode 100644 node_modules/resolve/lib/is-core.js delete mode 100644 node_modules/resolve/lib/node-modules-paths.js delete mode 100644 node_modules/resolve/lib/normalize-options.js delete mode 100644 node_modules/resolve/lib/sync.js delete mode 100644 node_modules/resolve/package.json delete mode 100644 node_modules/resolve/readme.markdown delete mode 100644 node_modules/resolve/test/core.js delete mode 100644 node_modules/resolve/test/dotdot.js delete mode 100644 node_modules/resolve/test/dotdot/abc/index.js delete mode 100644 node_modules/resolve/test/dotdot/index.js delete mode 100644 node_modules/resolve/test/faulty_basedir.js delete mode 100644 node_modules/resolve/test/filter.js delete mode 100644 node_modules/resolve/test/filter_sync.js delete mode 100644 node_modules/resolve/test/mock.js delete mode 100644 node_modules/resolve/test/mock_sync.js delete mode 100644 node_modules/resolve/test/module_dir.js delete mode 100644 node_modules/resolve/test/module_dir/xmodules/aaa/index.js delete mode 100644 node_modules/resolve/test/module_dir/ymodules/aaa/index.js delete mode 100644 node_modules/resolve/test/module_dir/zmodules/bbb/main.js delete mode 100644 node_modules/resolve/test/module_dir/zmodules/bbb/package.json delete mode 100644 node_modules/resolve/test/node-modules-paths.js delete mode 100644 node_modules/resolve/test/node_path.js delete mode 100644 node_modules/resolve/test/node_path/x/aaa/index.js delete mode 100644 node_modules/resolve/test/node_path/x/ccc/index.js delete mode 100644 node_modules/resolve/test/node_path/y/bbb/index.js delete mode 100644 node_modules/resolve/test/node_path/y/ccc/index.js delete mode 100644 node_modules/resolve/test/nonstring.js delete mode 100644 node_modules/resolve/test/pathfilter.js delete mode 100644 node_modules/resolve/test/pathfilter/deep_ref/main.js delete mode 100644 node_modules/resolve/test/precedence.js delete mode 100644 node_modules/resolve/test/precedence/aaa.js delete mode 100644 node_modules/resolve/test/precedence/aaa/index.js delete mode 100644 node_modules/resolve/test/precedence/aaa/main.js delete mode 100644 node_modules/resolve/test/precedence/bbb.js delete mode 100644 node_modules/resolve/test/precedence/bbb/main.js delete mode 100644 node_modules/resolve/test/resolver.js delete mode 100644 node_modules/resolve/test/resolver/baz/doom.js delete mode 100644 node_modules/resolve/test/resolver/baz/package.json delete mode 100644 node_modules/resolve/test/resolver/baz/quux.js delete mode 100644 node_modules/resolve/test/resolver/browser_field/a.js delete mode 100644 node_modules/resolve/test/resolver/browser_field/b.js delete mode 100644 node_modules/resolve/test/resolver/browser_field/package.json delete mode 100644 node_modules/resolve/test/resolver/cup.coffee delete mode 100644 node_modules/resolve/test/resolver/dot_main/index.js delete mode 100644 node_modules/resolve/test/resolver/dot_main/package.json delete mode 100644 node_modules/resolve/test/resolver/dot_slash_main/index.js delete mode 100644 node_modules/resolve/test/resolver/dot_slash_main/package.json delete mode 100644 node_modules/resolve/test/resolver/foo.js delete mode 100644 node_modules/resolve/test/resolver/incorrect_main/index.js delete mode 100644 node_modules/resolve/test/resolver/incorrect_main/package.json delete mode 100644 node_modules/resolve/test/resolver/invalid_main/package.json delete mode 100644 node_modules/resolve/test/resolver/mug.coffee delete mode 100644 node_modules/resolve/test/resolver/mug.js delete mode 100644 node_modules/resolve/test/resolver/multirepo/lerna.json delete mode 100644 node_modules/resolve/test/resolver/multirepo/package.json delete mode 100644 node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js delete mode 100644 node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json delete mode 100644 node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js delete mode 100644 node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json delete mode 100644 node_modules/resolve/test/resolver/nested_symlinks/mylib/async.js delete mode 100644 node_modules/resolve/test/resolver/nested_symlinks/mylib/package.json delete mode 100644 node_modules/resolve/test/resolver/nested_symlinks/mylib/sync.js delete mode 100644 node_modules/resolve/test/resolver/other_path/lib/other-lib.js delete mode 100644 node_modules/resolve/test/resolver/other_path/root.js delete mode 100644 node_modules/resolve/test/resolver/quux/foo/index.js delete mode 100644 node_modules/resolve/test/resolver/same_names/foo.js delete mode 100644 node_modules/resolve/test/resolver/same_names/foo/index.js delete mode 100644 node_modules/resolve/test/resolver/symlinked/_/node_modules/foo.js delete mode 100644 node_modules/resolve/test/resolver/symlinked/package/bar.js delete mode 100644 node_modules/resolve/test/resolver/symlinked/package/package.json delete mode 100644 node_modules/resolve/test/resolver/without_basedir/main.js delete mode 100644 node_modules/resolve/test/resolver_sync.js delete mode 100644 node_modules/resolve/test/shadowed_core.js delete mode 100644 node_modules/resolve/test/shadowed_core/node_modules/util/index.js delete mode 100644 node_modules/resolve/test/subdirs.js delete mode 100644 node_modules/resolve/test/symlinks.js diff --git a/node_modules/path-parse/LICENSE b/node_modules/path-parse/LICENSE deleted file mode 100644 index 810f3dbea83b5..0000000000000 --- a/node_modules/path-parse/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Javier Blanco - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/path-parse/index.js b/node_modules/path-parse/index.js deleted file mode 100644 index f062d0a23e629..0000000000000 --- a/node_modules/path-parse/index.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict'; - -var isWindows = process.platform === 'win32'; - -// Regex to split a windows path into into [dir, root, basename, name, ext] -var splitWindowsRe = - /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/; - -var win32 = {}; - -function win32SplitPath(filename) { - return splitWindowsRe.exec(filename).slice(1); -} - -win32.parse = function(pathString) { - if (typeof pathString !== 'string') { - throw new TypeError( - "Parameter 'pathString' must be a string, not " + typeof pathString - ); - } - var allParts = win32SplitPath(pathString); - if (!allParts || allParts.length !== 5) { - throw new TypeError("Invalid path '" + pathString + "'"); - } - return { - root: allParts[1], - dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1), - base: allParts[2], - ext: allParts[4], - name: allParts[3] - }; -}; - - - -// Split a filename into [dir, root, basename, name, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/; -var posix = {}; - - -function posixSplitPath(filename) { - return splitPathRe.exec(filename).slice(1); -} - - -posix.parse = function(pathString) { - if (typeof pathString !== 'string') { - throw new TypeError( - "Parameter 'pathString' must be a string, not " + typeof pathString - ); - } - var allParts = posixSplitPath(pathString); - if (!allParts || allParts.length !== 5) { - throw new TypeError("Invalid path '" + pathString + "'"); - } - - return { - root: allParts[1], - dir: allParts[0].slice(0, -1), - base: allParts[2], - ext: allParts[4], - name: allParts[3], - }; -}; - - -if (isWindows) - module.exports = win32.parse; -else /* posix */ - module.exports = posix.parse; - -module.exports.posix = posix.parse; -module.exports.win32 = win32.parse; diff --git a/node_modules/path-parse/package.json b/node_modules/path-parse/package.json deleted file mode 100644 index 36c23f84e7063..0000000000000 --- a/node_modules/path-parse/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "path-parse", - "version": "1.0.7", - "description": "Node.js path.parse() ponyfill", - "main": "index.js", - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/jbgutierrez/path-parse.git" - }, - "keywords": [ - "path", - "paths", - "file", - "dir", - "parse", - "built-in", - "util", - "utils", - "core", - "ponyfill", - "polyfill", - "shim" - ], - "author": "Javier Blanco ", - "license": "MIT", - "bugs": { - "url": "https://github.com/jbgutierrez/path-parse/issues" - }, - "homepage": "https://github.com/jbgutierrez/path-parse#readme" -} diff --git a/node_modules/resolve/LICENSE b/node_modules/resolve/LICENSE deleted file mode 100644 index ff4fce28af33a..0000000000000 --- a/node_modules/resolve/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2012 James Halliday - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/resolve/SECURITY.md b/node_modules/resolve/SECURITY.md deleted file mode 100644 index 82e4285adc628..0000000000000 --- a/node_modules/resolve/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Security - -Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. diff --git a/node_modules/resolve/appveyor.yml b/node_modules/resolve/appveyor.yml deleted file mode 100644 index 747fbdbba5e51..0000000000000 --- a/node_modules/resolve/appveyor.yml +++ /dev/null @@ -1,74 +0,0 @@ -version: 1.0.{build} -skip_branch_with_pr: true -build: off - -environment: - matrix: - #- nodejs_version: "15" - - nodejs_version: "14" - - nodejs_version: "13" - - nodejs_version: "12" - - nodejs_version: "11" - - nodejs_version: "10" - - nodejs_version: "9" - - nodejs_version: "8" - - nodejs_version: "7" - - nodejs_version: "6" - - nodejs_version: "5" - - nodejs_version: "4" - - nodejs_version: "3" - - nodejs_version: "2" - - nodejs_version: "1" - - nodejs_version: "0.12" - - nodejs_version: "0.10" - - nodejs_version: "0.8" - - nodejs_version: "0.6" -matrix: - # fast_finish: true - allow_failures: - - nodejs_version: "5" # due to windows npm bug, registry-side - - nodejs_version: "0.8" - # platform: x86 # x64 has started failing on the registry side, around early November 2020 - - nodejs_version: "0.6" - -platform: - - x86 - - x64 - -# Install scripts. (runs after repo cloning) -install: - # Fix symlinks in working copy (see https://github.com/appveyor/ci/issues/650#issuecomment-186592582) / https://github.com/charleskorn/batect/commit/d08986802ec43086902958c4ee7e57ff3e71dbef - - git config core.symlinks true - - git reset --hard - # Get the latest stable version of Node.js or io.js - - ps: if ($env:nodejs_version -ne '0.6') { Install-Product node $env:nodejs_version $env:platform } - - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform - - IF %nodejs_version% EQU 0.6 npm config set strict-ssl false && npm -g install npm@1.3 - - IF %nodejs_version% EQU 0.8 npm config set strict-ssl false && npm -g install npm@1.4.28 && npm install -g npm@4.5 - - IF %nodejs_version% EQU 1 npm -g install npm@2.9 - - IF %nodejs_version% EQU 2 npm -g install npm@4 - - IF %nodejs_version% EQU 3 npm -g install npm@4 - - IF %nodejs_version% EQU 4 npm -g install npm@5.3 - - IF %nodejs_version% EQU 5 npm -g install npm@5.3 - - IF %nodejs_version% EQU 6 npm -g install npm@6.9 - - IF %nodejs_version% EQU 7 npm -g install npm@6 - - IF %nodejs_version% EQU 8 npm -g install npm@6 - - IF %nodejs_version% EQU 9 npm -g install npm@6.9 - - IF %nodejs_version% EQU 10 npm -g install npm@7 - - IF %nodejs_version% EQU 11 npm -g install npm@7 - - IF %nodejs_version% EQU 12 npm -g install npm@7 - - IF %nodejs_version% EQU 13 npm -g install npm@7 - - IF %nodejs_version% EQU 14 npm -g install npm@7 - - IF %nodejs_version% EQU 15 npm -g install npm@7 - - set PATH=%APPDATA%\npm;%PATH% - #- IF %nodejs_version% NEQ 0.6 AND %nodejs_version% NEQ 0.8 npm -g install npm - # install modules - - npm install - -# Post-install test scripts. -test_script: - # Output useful info for debugging. - - node --version - - npm --version - # run tests - - npm run tests-only diff --git a/node_modules/resolve/example/async.js b/node_modules/resolve/example/async.js deleted file mode 100644 index 20e65dc281dba..0000000000000 --- a/node_modules/resolve/example/async.js +++ /dev/null @@ -1,5 +0,0 @@ -var resolve = require('../'); -resolve('tap', { basedir: __dirname }, function (err, res) { - if (err) console.error(err); - else console.log(res); -}); diff --git a/node_modules/resolve/example/sync.js b/node_modules/resolve/example/sync.js deleted file mode 100644 index 54b2cc1004223..0000000000000 --- a/node_modules/resolve/example/sync.js +++ /dev/null @@ -1,3 +0,0 @@ -var resolve = require('../'); -var res = resolve.sync('tap', { basedir: __dirname }); -console.log(res); diff --git a/node_modules/resolve/index.js b/node_modules/resolve/index.js deleted file mode 100644 index 125d814642359..0000000000000 --- a/node_modules/resolve/index.js +++ /dev/null @@ -1,6 +0,0 @@ -var async = require('./lib/async'); -async.core = require('./lib/core'); -async.isCore = require('./lib/is-core'); -async.sync = require('./lib/sync'); - -module.exports = async; diff --git a/node_modules/resolve/lib/async.js b/node_modules/resolve/lib/async.js deleted file mode 100644 index 02e80ac80e5fc..0000000000000 --- a/node_modules/resolve/lib/async.js +++ /dev/null @@ -1,320 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var caller = require('./caller'); -var nodeModulesPaths = require('./node-modules-paths'); -var normalizeOptions = require('./normalize-options'); -var isCore = require('is-core-module'); - -var realpathFS = fs.realpath && typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath; - -var defaultIsFile = function isFile(file, cb) { - fs.stat(file, function (err, stat) { - if (!err) { - return cb(null, stat.isFile() || stat.isFIFO()); - } - if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false); - return cb(err); - }); -}; - -var defaultIsDir = function isDirectory(dir, cb) { - 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); - }); -}; - -var defaultRealpath = function realpath(x, cb) { - realpathFS(x, function (realpathErr, realPath) { - if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr); - else cb(null, realpathErr ? x : realPath); - }); -}; - -var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) { - if (opts && opts.preserveSymlinks === false) { - realpath(x, cb); - } else { - cb(null, x); - } -}; - -var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) { - readFile(pkgfile, function (readFileErr, body) { - if (readFileErr) cb(readFileErr); - else { - try { - var pkg = JSON.parse(body); - cb(null, pkg); - } catch (jsonErr) { - cb(null); - } - } - }); -}; - -var getPackageCandidates = function getPackageCandidates(x, start, opts) { - var dirs = nodeModulesPaths(start, opts, x); - for (var i = 0; i < dirs.length; i++) { - dirs[i] = path.join(dirs[i], x); - } - return dirs; -}; - -module.exports = function resolve(x, options, callback) { - var cb = callback; - var opts = options; - if (typeof options === 'function') { - cb = opts; - opts = {}; - } - if (typeof x !== 'string') { - var err = new TypeError('Path must be a string.'); - return process.nextTick(function () { - cb(err); - }); - } - - opts = normalizeOptions(x, opts); - - var isFile = opts.isFile || defaultIsFile; - var isDirectory = opts.isDirectory || defaultIsDir; - var readFile = opts.readFile || fs.readFile; - var realpath = opts.realpath || defaultRealpath; - var readPackage = opts.readPackage || defaultReadPackage; - if (opts.readFile && opts.readPackage) { - var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.'); - return process.nextTick(function () { - cb(conflictErr); - }); - } - 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 = path.resolve(basedir); - - maybeRealpath( - realpath, - absoluteStart, - opts, - function (err, realStart) { - if (err) cb(err); - else init(realStart); - } - ); - - var res; - function init(basedir) { - if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) { - res = path.resolve(basedir, x); - if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/'; - if ((/\/$/).test(x) && res === basedir) { - loadAsDirectory(res, opts.package, onfile); - } else loadAsFile(res, opts.package, onfile); - } else if (includeCoreModules && isCore(x)) { - return cb(null, x); - } else loadNodeModules(x, basedir, function (err, n, pkg) { - if (err) cb(err); - else if (n) { - return maybeRealpath(realpath, n, opts, function (err, realN) { - if (err) { - cb(err); - } else { - cb(null, realN, pkg); - } - }); - } 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); - else if (m) cb(null, m, pkg); - else loadAsDirectory(res, function (err, d, pkg) { - if (err) cb(err); - else if (d) { - maybeRealpath(realpath, d, opts, function (err, realD) { - if (err) { - cb(err); - } else { - cb(null, realD, pkg); - } - }); - } else { - var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'"); - moduleError.code = 'MODULE_NOT_FOUND'; - cb(moduleError); - } - }); - } - - function loadAsFile(x, thePackage, callback) { - var loadAsFilePackage = thePackage; - var cb = callback; - if (typeof loadAsFilePackage === 'function') { - cb = loadAsFilePackage; - loadAsFilePackage = undefined; - } - - var exts = [''].concat(extensions); - load(exts, x, loadAsFilePackage); - - function load(exts, x, loadPackage) { - if (exts.length === 0) return cb(null, undefined, loadPackage); - var file = x + exts[0]; - - var pkg = loadPackage; - if (pkg) onpkg(null, pkg); - else loadpkg(path.dirname(file), onpkg); - - function onpkg(err, pkg_, dir) { - pkg = pkg_; - if (err) return cb(err); - if (dir && pkg && opts.pathFilter) { - var rfile = path.relative(dir, file); - var rel = rfile.slice(0, rfile.length - exts[0].length); - var r = opts.pathFilter(pkg, x, rel); - if (r) return load( - [''].concat(extensions.slice()), - path.resolve(dir, r), - pkg - ); - } - isFile(file, onex); - } - function onex(err, ex) { - if (err) return cb(err); - if (ex) return cb(null, file, pkg); - load(exts.slice(1), x, pkg); - } - } - } - - function loadpkg(dir, cb) { - if (dir === '' || dir === '/') return cb(null); - if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) { - return cb(null); - } - if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null); - - maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) { - if (unwrapErr) return loadpkg(path.dirname(dir), cb); - var pkgfile = path.join(pkgdir, 'package.json'); - isFile(pkgfile, function (err, ex) { - // on err, ex is false - if (!ex) return loadpkg(path.dirname(dir), cb); - - readPackage(readFile, pkgfile, function (err, pkgParam) { - if (err) cb(err); - - var pkg = pkgParam; - - if (pkg && opts.packageFilter) { - pkg = opts.packageFilter(pkg, pkgfile); - } - cb(null, pkg, dir); - }); - }); - }); - } - - function loadAsDirectory(x, loadAsDirectoryPackage, callback) { - var cb = callback; - var fpkg = loadAsDirectoryPackage; - if (typeof fpkg === 'function') { - cb = fpkg; - fpkg = opts.package; - } - - maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) { - if (unwrapErr) return cb(unwrapErr); - var pkgfile = path.join(pkgdir, 'package.json'); - isFile(pkgfile, function (err, ex) { - if (err) return cb(err); - if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb); - - readPackage(readFile, pkgfile, function (err, pkgParam) { - if (err) return cb(err); - - var pkg = pkgParam; - - if (pkg && opts.packageFilter) { - pkg = opts.packageFilter(pkg, pkgfile); - } - - if (pkg && 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'; - } - loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) { - if (err) return cb(err); - if (m) return cb(null, m, pkg); - if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb); - - var dir = path.resolve(x, pkg.main); - loadAsDirectory(dir, pkg, function (err, n, pkg) { - if (err) return cb(err); - if (n) return cb(null, n, pkg); - loadAsFile(path.join(x, 'index'), pkg, cb); - }); - }); - return; - } - - loadAsFile(path.join(x, '/index'), pkg, cb); - }); - }); - }); - } - - function processDirs(cb, dirs) { - if (dirs.length === 0) return cb(null, undefined); - var dir = dirs[0]; - - isDirectory(path.dirname(dir), isdir); - - function isdir(err, isdir) { - if (err) return cb(err); - if (!isdir) return processDirs(cb, dirs.slice(1)); - loadAsFile(dir, opts.package, onfile); - } - - function onfile(err, m, pkg) { - if (err) return cb(err); - if (m) return cb(null, m, pkg); - loadAsDirectory(dir, opts.package, ondir); - } - - function ondir(err, n, pkg) { - if (err) return cb(err); - if (n) return cb(null, n, pkg); - processDirs(cb, dirs.slice(1)); - } - } - function loadNodeModules(x, start, cb) { - var thunk = function () { return getPackageCandidates(x, start, opts); }; - processDirs( - cb, - packageIterator ? packageIterator(x, start, thunk, opts) : thunk() - ); - } -}; diff --git a/node_modules/resolve/lib/caller.js b/node_modules/resolve/lib/caller.js deleted file mode 100644 index b14a2804ae828..0000000000000 --- a/node_modules/resolve/lib/caller.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = function () { - // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi - var origPrepareStackTrace = Error.prepareStackTrace; - Error.prepareStackTrace = function (_, stack) { return stack; }; - var stack = (new Error()).stack; - Error.prepareStackTrace = origPrepareStackTrace; - return stack[2].getFileName(); -}; diff --git a/node_modules/resolve/lib/core.js b/node_modules/resolve/lib/core.js deleted file mode 100644 index c417d23c5a8ff..0000000000000 --- a/node_modules/resolve/lib/core.js +++ /dev/null @@ -1,53 +0,0 @@ -var current = (process.versions && process.versions.node && process.versions.node.split('.')) || []; - -function specifierIncluded(specifier) { - var parts = specifier.split(' '); - var op = parts.length > 1 ? parts[0] : '='; - var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.'); - - for (var i = 0; i < 3; ++i) { - var cur = parseInt(current[i] || 0, 10); - var ver = parseInt(versionParts[i] || 0, 10); - if (cur === ver) { - continue; // eslint-disable-line no-restricted-syntax, no-continue - } - if (op === '<') { - return cur < ver; - } else if (op === '>=') { - return cur >= ver; - } else { - return false; - } - } - return op === '>='; -} - -function matchesRange(range) { - var specifiers = range.split(/ ?&& ?/); - if (specifiers.length === 0) { return false; } - for (var i = 0; i < specifiers.length; ++i) { - if (!specifierIncluded(specifiers[i])) { return false; } - } - return true; -} - -function versionIncluded(specifierValue) { - if (typeof specifierValue === 'boolean') { return specifierValue; } - if (specifierValue && typeof specifierValue === 'object') { - for (var i = 0; i < specifierValue.length; ++i) { - if (matchesRange(specifierValue[i])) { return true; } - } - return false; - } - return matchesRange(specifierValue); -} - -var data = require('./core.json'); - -var core = {}; -for (var mod in data) { // eslint-disable-line no-restricted-syntax - if (Object.prototype.hasOwnProperty.call(data, mod)) { - core[mod] = versionIncluded(data[mod]); - } -} -module.exports = core; diff --git a/node_modules/resolve/lib/core.json b/node_modules/resolve/lib/core.json deleted file mode 100644 index 0238b61a4c71e..0000000000000 --- a/node_modules/resolve/lib/core.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "assert": true, - "assert/strict": ">= 15", - "async_hooks": ">= 8", - "buffer_ieee754": "< 0.9.7", - "buffer": true, - "child_process": true, - "cluster": true, - "console": true, - "constants": true, - "crypto": true, - "_debug_agent": ">= 1 && < 8", - "_debugger": "< 8", - "dgram": true, - "diagnostics_channel": ">= 15.1", - "dns": true, - "dns/promises": ">= 15", - "domain": ">= 0.7.12", - "events": true, - "freelist": "< 6", - "fs": true, - "fs/promises": [">= 10 && < 10.1", ">= 14"], - "_http_agent": ">= 0.11.1", - "_http_client": ">= 0.11.1", - "_http_common": ">= 0.11.1", - "_http_incoming": ">= 0.11.1", - "_http_outgoing": ">= 0.11.1", - "_http_server": ">= 0.11.1", - "http": true, - "http2": ">= 8.8", - "https": true, - "inspector": ">= 8.0.0", - "_linklist": "< 8", - "module": true, - "net": true, - "node-inspect/lib/_inspect": ">= 7.6.0 && < 12", - "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12", - "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12", - "os": true, - "path": true, - "path/posix": ">= 15.3", - "path/win32": ">= 15.3", - "perf_hooks": ">= 8.5", - "process": ">= 1", - "punycode": true, - "querystring": true, - "readline": true, - "repl": true, - "smalloc": ">= 0.11.5 && < 3", - "_stream_duplex": ">= 0.9.4", - "_stream_transform": ">= 0.9.4", - "_stream_wrap": ">= 1.4.1", - "_stream_passthrough": ">= 0.9.4", - "_stream_readable": ">= 0.9.4", - "_stream_writable": ">= 0.9.4", - "stream": true, - "stream/promises": ">= 15", - "string_decoder": true, - "sys": [">= 0.6 && < 0.7", ">= 0.8"], - "timers": true, - "timers/promises": ">= 15", - "_tls_common": ">= 0.11.13", - "_tls_legacy": ">= 0.11.3 && < 10", - "_tls_wrap": ">= 0.11.3", - "tls": true, - "trace_events": ">= 10", - "tty": true, - "url": true, - "util": true, - "util/types": ">= 15.3", - "v8/tools/arguments": ">= 10 && < 12", - "v8/tools/codemap": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8/tools/consarray": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8/tools/csvparser": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8/tools/logreader": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8/tools/profile_view": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], - "v8": ">= 1", - "vm": true, - "wasi": ">= 13.4 && < 13.5", - "worker_threads": ">= 11.7", - "zlib": true -} diff --git a/node_modules/resolve/lib/is-core.js b/node_modules/resolve/lib/is-core.js deleted file mode 100644 index 537f5c782ffe5..0000000000000 --- a/node_modules/resolve/lib/is-core.js +++ /dev/null @@ -1,5 +0,0 @@ -var isCoreModule = require('is-core-module'); - -module.exports = function isCore(x) { - return isCoreModule(x); -}; diff --git a/node_modules/resolve/lib/node-modules-paths.js b/node_modules/resolve/lib/node-modules-paths.js deleted file mode 100644 index 2b43813a7a561..0000000000000 --- a/node_modules/resolve/lib/node-modules-paths.js +++ /dev/null @@ -1,42 +0,0 @@ -var path = require('path'); -var parse = path.parse || require('path-parse'); - -var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) { - var prefix = '/'; - if ((/^([A-Za-z]:)/).test(absoluteStart)) { - prefix = ''; - } else if ((/^\\\\/).test(absoluteStart)) { - prefix = '\\\\'; - } - - var paths = [absoluteStart]; - var parsed = parse(absoluteStart); - while (parsed.dir !== paths[paths.length - 1]) { - paths.push(parsed.dir); - parsed = parse(parsed.dir); - } - - return paths.reduce(function (dirs, aPath) { - return dirs.concat(modules.map(function (moduleDir) { - return path.resolve(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; -}; diff --git a/node_modules/resolve/lib/normalize-options.js b/node_modules/resolve/lib/normalize-options.js deleted file mode 100644 index 4b56904eaea72..0000000000000 --- a/node_modules/resolve/lib/normalize-options.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = function (x, opts) { - /** - * This file is purposefully a passthrough. It's expected that third-party - * environments will override it at runtime in order to inject special logic - * into `resolve` (by manipulating the options). One such example is the PnP - * code path in Yarn. - */ - - return opts || {}; -}; diff --git a/node_modules/resolve/lib/sync.js b/node_modules/resolve/lib/sync.js deleted file mode 100644 index ef9bd803ceeda..0000000000000 --- a/node_modules/resolve/lib/sync.js +++ /dev/null @@ -1,199 +0,0 @@ -var isCore = require('is-core-module'); -var fs = require('fs'); -var path = require('path'); -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 { - var stat = fs.statSync(file); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; - throw e; - } - return stat.isFile() || stat.isFIFO(); -}; - -var defaultIsDir = function isDirectory(dir) { - try { - var stat = fs.statSync(dir); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; - throw e; - } - return stat.isDirectory(); -}; - -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 defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) { - var body = readFileSync(pkgfile); - try { - var pkg = JSON.parse(body); - return pkg; - } catch (jsonErr) {} -}; - -var getPackageCandidates = function getPackageCandidates(x, start, opts) { - var dirs = nodeModulesPaths(start, opts, x); - for (var i = 0; i < dirs.length; i++) { - dirs[i] = path.join(dirs[i], x); - } - return dirs; -}; - -module.exports = function resolveSync(x, options) { - if (typeof x !== 'string') { - throw new TypeError('Path must be a string.'); - } - var opts = normalizeOptions(x, options); - - var isFile = opts.isFile || defaultIsFile; - var readFileSync = opts.readFileSync || fs.readFileSync; - var isDirectory = opts.isDirectory || defaultIsDir; - var realpathSync = opts.realpathSync || defaultRealpathSync; - var readPackageSync = opts.readPackageSync || defaultReadPackageSync; - if (opts.readFileSync && opts.readPackageSync) { - throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.'); - } - 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 = maybeRealpathSync(realpathSync, path.resolve(basedir), opts); - - if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) { - var res = path.resolve(absoluteStart, x); - if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/'; - var m = loadAsFileSync(res) || loadAsDirectorySync(res); - if (m) return maybeRealpathSync(realpathSync, m, opts); - } else if (includeCoreModules && isCore(x)) { - return x; - } else { - var n = loadNodeModulesSync(x, absoluteStart); - if (n) return maybeRealpathSync(realpathSync, n, opts); - } - - var err = new Error("Cannot find module '" + x + "' from '" + parent + "'"); - err.code = 'MODULE_NOT_FOUND'; - throw err; - - function loadAsFileSync(x) { - var pkg = loadpkg(path.dirname(x)); - - if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) { - var rfile = path.relative(pkg.dir, x); - var r = opts.pathFilter(pkg.pkg, x, rfile); - if (r) { - x = path.resolve(pkg.dir, r); // eslint-disable-line no-param-reassign - } - } - - if (isFile(x)) { - return x; - } - - for (var i = 0; i < extensions.length; i++) { - var file = x + extensions[i]; - if (isFile(file)) { - return file; - } - } - } - - function loadpkg(dir) { - if (dir === '' || dir === '/') return; - if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) { - return; - } - if ((/[/\\]node_modules[/\\]*$/).test(dir)) return; - - var pkgfile = path.join(maybeRealpathSync(realpathSync, dir, opts), 'package.json'); - - if (!isFile(pkgfile)) { - return loadpkg(path.dirname(dir)); - } - - var pkg = readPackageSync(readFileSync, pkgfile); - - if (pkg && opts.packageFilter) { - // v2 will pass pkgfile - pkg = opts.packageFilter(pkg, /*pkgfile,*/ dir); // eslint-disable-line spaced-comment - } - - return { pkg: pkg, dir: dir }; - } - - function loadAsDirectorySync(x) { - var pkgfile = path.join(maybeRealpathSync(realpathSync, x, opts), '/package.json'); - if (isFile(pkgfile)) { - try { - var pkg = readPackageSync(readFileSync, pkgfile); - } catch (e) {} - - if (pkg && opts.packageFilter) { - // v2 will pass pkgfile - pkg = opts.packageFilter(pkg, /*pkgfile,*/ x); // eslint-disable-line spaced-comment - } - - if (pkg && 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 === '.' || 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) {} - } - } - - return loadAsFileSync(path.join(x, '/index')); - } - - function loadNodeModulesSync(x, start) { - var thunk = function () { return getPackageCandidates(x, start, opts); }; - var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk(); - - for (var i = 0; i < dirs.length; i++) { - var dir = dirs[i]; - if (isDirectory(path.dirname(dir))) { - var m = loadAsFileSync(dir); - if (m) return m; - var n = loadAsDirectorySync(dir); - if (n) return n; - } - } - } -}; diff --git a/node_modules/resolve/package.json b/node_modules/resolve/package.json deleted file mode 100644 index 52a78a2338a60..0000000000000 --- a/node_modules/resolve/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "resolve", - "description": "resolve like require.resolve() on behalf of files asynchronously and synchronously", - "version": "1.20.0", - "repository": { - "type": "git", - "url": "git://github.com/browserify/resolve.git" - }, - "main": "index.js", - "keywords": [ - "resolve", - "require", - "node", - "module" - ], - "scripts": { - "prepublish": "safe-publish-latest && cp node_modules/is-core-module/core.json ./lib/ ||:", - "prelint": "eclint check '**/*'", - "lint": "eslint --ext=js,mjs .", - "pretests-only": "cd ./test/resolver/nested_symlinks && node mylib/sync && node mylib/async", - "tests-only": "tape test/*.js", - "pretest": "npm run lint", - "test": "npm run --silent tests-only", - "posttest": "npm run test:multirepo && aud --production", - "test:multirepo": "cd ./test/resolver/multirepo && npm install && npm test" - }, - "devDependencies": { - "@ljharb/eslint-config": "^17.5.1", - "array.prototype.map": "^1.0.3", - "aud": "^1.1.4", - "eclint": "^2.8.1", - "eslint": "^7.19.0", - "object-keys": "^1.1.1", - "safe-publish-latest": "^1.1.4", - "tap": "0.4.13", - "tape": "^5.1.1" - }, - "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - }, - "dependencies": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } -} diff --git a/node_modules/resolve/readme.markdown b/node_modules/resolve/readme.markdown deleted file mode 100644 index 7c9f2dcd53397..0000000000000 --- a/node_modules/resolve/readme.markdown +++ /dev/null @@ -1,279 +0,0 @@ -# resolve - -implements the [node `require.resolve()` -algorithm](https://nodejs.org/api/modules.html#modules_all_together) -such that you can `require.resolve()` on behalf of a file asynchronously and -synchronously - -[![build status](https://secure.travis-ci.org/browserify/resolve.png)](http://travis-ci.org/browserify/resolve) - -# example - -asynchronously resolve: - -```js -var resolve = require('resolve'); -resolve('tap', { basedir: __dirname }, function (err, res) { - if (err) console.error(err); - else console.log(res); -}); -``` - -``` -$ node example/async.js -/home/substack/projects/node-resolve/node_modules/tap/lib/main.js -``` - -synchronously resolve: - -```js -var resolve = require('resolve'); -var res = resolve.sync('tap', { basedir: __dirname }); -console.log(res); -``` - -``` -$ node example/sync.js -/home/substack/projects/node-resolve/node_modules/tap/lib/main.js -``` - -# methods - -```js -var resolve = require('resolve'); -``` - -For both the synchronous and asynchronous methods, errors may have any of the following `err.code` values: - -- `MODULE_NOT_FOUND`: the given path string (`id`) could not be resolved to a module -- `INVALID_BASEDIR`: the specified `opts.basedir` doesn't exist, or is not a directory -- `INVALID_PACKAGE_MAIN`: a `package.json` was encountered with an invalid `main` property (eg. not a string) - -## resolve(id, opts={}, cb) - -Asynchronously resolve the module path string `id` into `cb(err, res [, pkg])`, where `pkg` (if defined) is the data from `package.json`. - -options are: - -* opts.basedir - directory to begin resolving from - -* opts.package - `package.json` data applicable to the module being loaded - -* opts.extensions - array of file extensions to search in order - -* opts.includeCoreModules - set to `false` to exclude node core modules (e.g. `fs`) from the search - -* opts.readFile - how to read files asynchronously - -* opts.isFile - function to asynchronously test whether a file exists - -* opts.isDirectory - function to asynchronously test whether a directory exists - -* opts.realpath - function to asynchronously resolve a potential symlink to its real path - -* `opts.readPackage(readFile, pkgfile, cb)` - function to asynchronously read and parse a package.json file - * readFile - the passed `opts.readFile` or `fs.readFile` if not specified - * pkgfile - path to package.json - * cb - callback - -* `opts.packageFilter(pkg, pkgfile, dir)` - transform the parsed package.json contents before looking at the "main" field - * pkg - package data - * pkgfile - path to package.json - * dir - directory for package.json - -* `opts.pathFilter(pkg, path, relativePath)` - transform a path within a package - * pkg - package data - * path - the path being resolved - * relativePath - the path relative from the package.json location - * returns - a relative path that will be joined from the package.json location - -* 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.packageIterator(request, start, opts)` - return the list of candidate paths where the packages sources may be found (probably don't use this) - * request - the import specifier being resolved - * start - lookup path - * getPackageCandidates - 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. -This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag. -**Note:** this property is currently `true` by default but it will be changed to -`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*. - -default `opts` values: - -```js -{ - paths: [], - basedir: __dirname, - extensions: ['.js'], - includeCoreModules: true, - readFile: fs.readFile, - isFile: function isFile(file, cb) { - fs.stat(file, function (err, stat) { - if (!err) { - return cb(null, stat.isFile() || stat.isFIFO()); - } - if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false); - return cb(err); - }); - }, - isDirectory: function isDirectory(dir, cb) { - 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); - }); - }, - realpath: function realpath(file, cb) { - var realpath = typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath; - realpath(file, function (realPathErr, realPath) { - if (realPathErr && realPathErr.code !== 'ENOENT') cb(realPathErr); - else cb(null, realPathErr ? file : realPath); - }); - }, - readPackage: function defaultReadPackage(readFile, pkgfile, cb) { - readFile(pkgfile, function (readFileErr, body) { - if (readFileErr) cb(readFileErr); - else { - try { - var pkg = JSON.parse(body); - cb(null, pkg); - } catch (jsonErr) { - cb(null); - } - } - }); - }, - moduleDirectory: 'node_modules', - preserveSymlinks: true -} -``` - -## resolve.sync(id, opts) - -Synchronously resolve the module path string `id`, returning the result and -throwing an error when `id` can't be resolved. - -options are: - -* opts.basedir - directory to begin resolving from - -* opts.extensions - array of file extensions to search in order - -* opts.includeCoreModules - set to `false` to exclude node core modules (e.g. `fs`) from the search - -* opts.readFileSync - how to read files synchronously - -* opts.isFile - function to synchronously test whether a file exists - -* opts.isDirectory - function to synchronously test whether a directory exists - -* opts.realpathSync - function to synchronously resolve a potential symlink to its real path - -* `opts.readPackageSync(readFileSync, pkgfile)` - function to synchronously read and parse a package.json file - * readFileSync - the passed `opts.readFileSync` or `fs.readFileSync` if not specified - * pkgfile - path to package.json - -* `opts.packageFilter(pkg, dir)` - transform the parsed package.json contents before looking at the "main" field - * pkg - package data - * dir - directory for package.json (Note: the second argument will change to "pkgfile" in v2) - -* `opts.pathFilter(pkg, path, relativePath)` - transform a path within a package - * pkg - package data - * path - the path being resolved - * relativePath - the path relative from the package.json location - * returns - a relative path that will be joined from the package.json location - -* 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.packageIterator(request, start, opts)` - return the list of candidate paths where the packages sources may be found (probably don't use this) - * request - the import specifier being resolved - * start - lookup path - * getPackageCandidates - 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. -This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag. -**Note:** this property is currently `true` by default but it will be changed to -`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*. - -default `opts` values: - -```js -{ - paths: [], - basedir: __dirname, - extensions: ['.js'], - includeCoreModules: true, - readFileSync: fs.readFileSync, - isFile: function isFile(file) { - try { - var stat = fs.statSync(file); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; - throw e; - } - return stat.isFile() || stat.isFIFO(); - }, - isDirectory: function isDirectory(dir) { - try { - var stat = fs.statSync(dir); - } catch (e) { - if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; - throw e; - } - return stat.isDirectory(); - }, - realpathSync: function realpathSync(file) { - try { - var realpath = typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync; - return realpath(file); - } catch (realPathErr) { - if (realPathErr.code !== 'ENOENT') { - throw realPathErr; - } - } - return file; - }, - readPackageSync: function defaultReadPackageSync(readFileSync, pkgfile) { - var body = readFileSync(pkgfile); - try { - var pkg = JSON.parse(body); - return pkg; - } catch (jsonErr) {} - }, - moduleDirectory: 'node_modules', - preserveSymlinks: true -} -``` - -# install - -With [npm](https://npmjs.org) do: - -```sh -npm install resolve -``` - -# license - -MIT diff --git a/node_modules/resolve/test/core.js b/node_modules/resolve/test/core.js deleted file mode 100644 index 7a3ccb16b435d..0000000000000 --- a/node_modules/resolve/test/core.js +++ /dev/null @@ -1,81 +0,0 @@ -var test = require('tape'); -var keys = require('object-keys'); -var resolve = require('../'); - -test('core modules', function (t) { - t.test('isCore()', function (st) { - st.ok(resolve.isCore('fs')); - st.ok(resolve.isCore('net')); - st.ok(resolve.isCore('http')); - - st.ok(!resolve.isCore('seq')); - st.ok(!resolve.isCore('../')); - - st.ok(!resolve.isCore('toString')); - - st.end(); - }); - - t.test('core list', function (st) { - var cores = keys(resolve.core); - st.plan(cores.length); - - for (var i = 0; i < cores.length; ++i) { - var mod = cores[i]; - var requireFunc = function () { require(mod); }; // eslint-disable-line no-loop-func - console.log(mod, resolve.core, resolve.core[mod]); - if (resolve.core[mod]) { - st.doesNotThrow(requireFunc, mod + ' supported; requiring does not throw'); - } else { - st.throws(requireFunc, mod + ' not supported; requiring throws'); - } - } - - st.end(); - }); - - t.test('core via repl module', { skip: !resolve.core.repl }, function (st) { - var libs = require('repl')._builtinLibs; // eslint-disable-line no-underscore-dangle - if (!libs) { - st.skip('module.builtinModules does not exist'); - return st.end(); - } - for (var i = 0; i < libs.length; ++i) { - var mod = libs[i]; - st.ok(resolve.core[mod], mod + ' is a core module'); - st.doesNotThrow( - function () { require(mod); }, // eslint-disable-line no-loop-func - 'requiring ' + mod + ' does not throw' - ); - } - st.end(); - }); - - t.test('core via builtinModules list', { skip: !resolve.core.module }, function (st) { - var libs = require('module').builtinModules; - if (!libs) { - st.skip('module.builtinModules does not exist'); - return st.end(); - } - var blacklist = [ - '_debug_agent', - 'v8/tools/tickprocessor-driver', - 'v8/tools/SourceMap', - 'v8/tools/tickprocessor', - 'v8/tools/profile' - ]; - for (var i = 0; i < libs.length; ++i) { - var mod = libs[i]; - if (blacklist.indexOf(mod) === -1) { - st.ok(resolve.core[mod], mod + ' is a core module'); - st.doesNotThrow( - function () { require(mod); }, // eslint-disable-line no-loop-func - 'requiring ' + mod + ' does not throw' - ); - } - } - st.end(); - }); - - t.end(); -}); diff --git a/node_modules/resolve/test/dotdot.js b/node_modules/resolve/test/dotdot.js deleted file mode 100644 index 30806659be2ef..0000000000000 --- a/node_modules/resolve/test/dotdot.js +++ /dev/null @@ -1,29 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('dotdot', function (t) { - t.plan(4); - var dir = path.join(__dirname, '/dotdot/abc'); - - resolve('..', { basedir: dir }, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(__dirname, 'dotdot/index.js')); - }); - - resolve('.', { basedir: dir }, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, 'index.js')); - }); -}); - -test('dotdot sync', function (t) { - t.plan(2); - var dir = path.join(__dirname, '/dotdot/abc'); - - var a = resolve.sync('..', { basedir: dir }); - t.equal(a, path.join(__dirname, 'dotdot/index.js')); - - var b = resolve.sync('.', { basedir: dir }); - t.equal(b, path.join(dir, 'index.js')); -}); diff --git a/node_modules/resolve/test/dotdot/abc/index.js b/node_modules/resolve/test/dotdot/abc/index.js deleted file mode 100644 index 67f2534ebf90d..0000000000000 --- a/node_modules/resolve/test/dotdot/abc/index.js +++ /dev/null @@ -1,2 +0,0 @@ -var x = require('..'); -console.log(x); diff --git a/node_modules/resolve/test/dotdot/index.js b/node_modules/resolve/test/dotdot/index.js deleted file mode 100644 index 643f9fcc6a6a7..0000000000000 --- a/node_modules/resolve/test/dotdot/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'whatever'; diff --git a/node_modules/resolve/test/faulty_basedir.js b/node_modules/resolve/test/faulty_basedir.js deleted file mode 100644 index 5f2141a67267b..0000000000000 --- a/node_modules/resolve/test/faulty_basedir.js +++ /dev/null @@ -1,29 +0,0 @@ -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) { - t.plan(1); - - var resolverDir = 'C:\\a\\b\\c\\d'; - - resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) { - 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); - }); -}); diff --git a/node_modules/resolve/test/filter.js b/node_modules/resolve/test/filter.js deleted file mode 100644 index 8f8cccdb2f59f..0000000000000 --- a/node_modules/resolve/test/filter.js +++ /dev/null @@ -1,34 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('filter', function (t) { - t.plan(4); - var dir = path.join(__dirname, 'resolver'); - var packageFilterArgs; - resolve('./baz', { - basedir: dir, - packageFilter: function (pkg, pkgfile) { - pkg.main = 'doom'; // eslint-disable-line no-param-reassign - packageFilterArgs = [pkg, pkgfile]; - return pkg; - } - }, function (err, res, pkg) { - if (err) t.fail(err); - - t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works'); - - var packageData = packageFilterArgs[0]; - t.equal(pkg, packageData, 'first packageFilter argument is "pkg"'); - t.equal(packageData.main, 'doom', 'package "main" was altered'); - - var packageFile = packageFilterArgs[1]; - t.equal( - packageFile, - path.join(dir, 'baz/package.json'), - 'second packageFilter argument is "pkgfile"' - ); - - t.end(); - }); -}); diff --git a/node_modules/resolve/test/filter_sync.js b/node_modules/resolve/test/filter_sync.js deleted file mode 100644 index 8a43b9818973d..0000000000000 --- a/node_modules/resolve/test/filter_sync.js +++ /dev/null @@ -1,33 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('filter', function (t) { - var dir = path.join(__dirname, 'resolver'); - var packageFilterArgs; - var res = resolve.sync('./baz', { - basedir: dir, - // NOTE: in v2.x, this will be `pkg, pkgfile, dir`, but must remain "broken" here in v1.x for compatibility - packageFilter: function (pkg, /*pkgfile,*/ dir) { // eslint-disable-line spaced-comment - pkg.main = 'doom'; // eslint-disable-line no-param-reassign - packageFilterArgs = 'is 1.x' ? [pkg, dir] : [pkg, pkgfile, dir]; // eslint-disable-line no-constant-condition, no-undef - return pkg; - } - }); - - t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works'); - - var packageData = packageFilterArgs[0]; - t.equal(packageData.main, 'doom', 'package "main" was altered'); - - if (!'is 1.x') { // eslint-disable-line no-constant-condition - var packageFile = packageFilterArgs[1]; - t.equal(packageFile, path.join(dir, 'baz', 'package.json'), 'package.json path is correct'); - } - - var packageDir = packageFilterArgs['is 1.x' ? 1 : 2]; // eslint-disable-line no-constant-condition - // eslint-disable-next-line no-constant-condition - t.equal(packageDir, path.join(dir, 'baz'), ('is 1.x' ? 'second' : 'third') + ' packageFilter argument is "dir"'); - - t.end(); -}); diff --git a/node_modules/resolve/test/mock.js b/node_modules/resolve/test/mock.js deleted file mode 100644 index 6116275498895..0000000000000 --- a/node_modules/resolve/test/mock.js +++ /dev/null @@ -1,315 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('mock', function (t) { - t.plan(8); - - var files = {}; - files[path.resolve('/foo/bar/baz.js')] = 'beep'; - - var dirs = {}; - dirs[path.resolve('/foo/bar')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file))); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - readFile: function (file, cb) { - cb(null, files[path.resolve(file)]); - }, - realpath: function (file, cb) { - cb(null, file); - } - }; - } - - resolve('./baz', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/baz.js')); - t.equal(pkg, undefined); - }); - - resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/baz.js')); - t.equal(pkg, undefined); - }); - - resolve('baz', opts('/foo/bar'), function (err, res) { - t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); - - resolve('../baz', opts('/foo/bar'), function (err, res) { - t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); -}); - -test('mock from package', function (t) { - t.plan(8); - - var files = {}; - files[path.resolve('/foo/bar/baz.js')] = 'beep'; - - var dirs = {}; - dirs[path.resolve('/foo/bar')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, file)); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - 'package': { main: 'bar' }, - readFile: function (file, cb) { - cb(null, files[file]); - }, - realpath: function (file, cb) { - cb(null, file); - } - }; - } - - resolve('./baz', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/baz.js')); - t.equal(pkg && pkg.main, 'bar'); - }); - - resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/baz.js')); - t.equal(pkg && pkg.main, 'bar'); - }); - - resolve('baz', opts('/foo/bar'), function (err, res) { - t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); - - resolve('../baz', opts('/foo/bar'), function (err, res) { - t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); -}); - -test('mock package', function (t) { - t.plan(2); - - var files = {}; - files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep'; - files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({ - main: './baz.js' - }); - - var dirs = {}; - dirs[path.resolve('/foo')] = true; - dirs[path.resolve('/foo/node_modules')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file))); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - readFile: function (file, cb) { - cb(null, files[path.resolve(file)]); - }, - realpath: function (file, cb) { - cb(null, file); - } - }; - } - - resolve('bar', opts('/foo'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/node_modules/bar/baz.js')); - t.equal(pkg && pkg.main, './baz.js'); - }); -}); - -test('mock package from package', function (t) { - t.plan(2); - - var files = {}; - files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep'; - files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({ - main: './baz.js' - }); - - var dirs = {}; - dirs[path.resolve('/foo')] = true; - dirs[path.resolve('/foo/node_modules')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file))); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - 'package': { main: 'bar' }, - readFile: function (file, cb) { - cb(null, files[path.resolve(file)]); - }, - realpath: function (file, cb) { - cb(null, file); - } - }; - } - - resolve('bar', opts('/foo'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/node_modules/bar/baz.js')); - t.equal(pkg && pkg.main, './baz.js'); - }); -}); - -test('symlinked', function (t) { - t.plan(4); - - var files = {}; - files[path.resolve('/foo/bar/baz.js')] = 'beep'; - files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep'; - - var dirs = {}; - dirs[path.resolve('/foo/bar')] = true; - dirs[path.resolve('/foo/bar/symlinked')] = true; - - function opts(basedir) { - return { - preserveSymlinks: false, - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file))); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - readFile: function (file, cb) { - cb(null, files[path.resolve(file)]); - }, - realpath: function (file, cb) { - var resolved = path.resolve(file); - - if (resolved.indexOf('symlinked') >= 0) { - cb(null, resolved); - return; - } - - var ext = path.extname(resolved); - - if (ext) { - var dir = path.dirname(resolved); - var base = path.basename(resolved); - cb(null, path.join(dir, 'symlinked', base)); - } else { - cb(null, path.join(resolved, 'symlinked')); - } - } - }; - } - - resolve('./baz', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/symlinked/baz.js')); - t.equal(pkg, undefined); - }); - - resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) { - if (err) return t.fail(err); - t.equal(res, path.resolve('/foo/bar/symlinked/baz.js')); - t.equal(pkg, undefined); - }); -}); - -test('readPackage', function (t) { - t.plan(3); - - var files = {}; - files[path.resolve('/foo/node_modules/bar/something-else.js')] = 'beep'; - files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({ - main: './baz.js' - }); - files[path.resolve('/foo/node_modules/bar/baz.js')] = 'boop'; - - var dirs = {}; - dirs[path.resolve('/foo')] = true; - dirs[path.resolve('/foo/node_modules')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file, cb) { - cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file))); - }, - isDirectory: function (dir, cb) { - cb(null, !!dirs[path.resolve(dir)]); - }, - 'package': { main: 'bar' }, - readFile: function (file, cb) { - cb(null, files[path.resolve(file)]); - }, - realpath: function (file, cb) { - cb(null, file); - } - }; - } - - t.test('with readFile', function (st) { - st.plan(3); - - resolve('bar', opts('/foo'), function (err, res, pkg) { - st.error(err); - st.equal(res, path.resolve('/foo/node_modules/bar/baz.js')); - st.equal(pkg && pkg.main, './baz.js'); - }); - }); - - var readPackage = function (readFile, file, cb) { - var barPackage = path.join('bar', 'package.json'); - if (file.slice(-barPackage.length) === barPackage) { - cb(null, { main: './something-else.js' }); - } else { - cb(null, JSON.parse(files[path.resolve(file)])); - } - }; - - t.test('with readPackage', function (st) { - st.plan(3); - - var options = opts('/foo'); - delete options.readFile; - options.readPackage = readPackage; - resolve('bar', options, function (err, res, pkg) { - st.error(err); - st.equal(res, path.resolve('/foo/node_modules/bar/something-else.js')); - st.equal(pkg && pkg.main, './something-else.js'); - }); - }); - - t.test('with readFile and readPackage', function (st) { - st.plan(1); - - var options = opts('/foo'); - options.readPackage = readPackage; - resolve('bar', options, function (err) { - st.throws(function () { throw err; }, TypeError, 'errors when both readFile and readPackage are provided'); - }); - }); -}); diff --git a/node_modules/resolve/test/mock_sync.js b/node_modules/resolve/test/mock_sync.js deleted file mode 100644 index 0e3a60d4414b6..0000000000000 --- a/node_modules/resolve/test/mock_sync.js +++ /dev/null @@ -1,216 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('mock', function (t) { - t.plan(4); - - var files = {}; - files[path.resolve('/foo/bar/baz.js')] = 'beep'; - - var dirs = {}; - dirs[path.resolve('/foo/bar')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file) { - return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); - }, - isDirectory: function (dir) { - return !!dirs[path.resolve(dir)]; - }, - readFileSync: function (file) { - return files[path.resolve(file)]; - }, - realpathSync: function (file) { - return file; - } - }; - } - - t.equal( - resolve.sync('./baz', opts('/foo/bar')), - path.resolve('/foo/bar/baz.js') - ); - - t.equal( - resolve.sync('./baz.js', opts('/foo/bar')), - path.resolve('/foo/bar/baz.js') - ); - - t.throws(function () { - resolve.sync('baz', opts('/foo/bar')); - }); - - t.throws(function () { - resolve.sync('../baz', opts('/foo/bar')); - }); -}); - -test('mock package', function (t) { - t.plan(1); - - var files = {}; - files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep'; - files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({ - main: './baz.js' - }); - - var dirs = {}; - dirs[path.resolve('/foo')] = true; - dirs[path.resolve('/foo/node_modules')] = true; - - function opts(basedir) { - return { - basedir: path.resolve(basedir), - isFile: function (file) { - return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); - }, - isDirectory: function (dir) { - return !!dirs[path.resolve(dir)]; - }, - readFileSync: function (file) { - return files[path.resolve(file)]; - }, - realpathSync: function (file) { - return file; - } - }; - } - - t.equal( - resolve.sync('bar', opts('/foo')), - path.resolve('/foo/node_modules/bar/baz.js') - ); -}); - -test('symlinked', function (t) { - t.plan(2); - - var files = {}; - files[path.resolve('/foo/bar/baz.js')] = 'beep'; - files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep'; - - var dirs = {}; - dirs[path.resolve('/foo/bar')] = true; - dirs[path.resolve('/foo/bar/symlinked')] = true; - - function opts(basedir) { - return { - preserveSymlinks: false, - basedir: path.resolve(basedir), - isFile: function (file) { - return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); - }, - isDirectory: function (dir) { - return !!dirs[path.resolve(dir)]; - }, - readFileSync: function (file) { - return files[path.resolve(file)]; - }, - realpathSync: function (file) { - var resolved = path.resolve(file); - - if (resolved.indexOf('symlinked') >= 0) { - return resolved; - } - - var ext = path.extname(resolved); - - if (ext) { - var dir = path.dirname(resolved); - var base = path.basename(resolved); - return path.join(dir, 'symlinked', base); - } else { - return path.join(resolved, 'symlinked'); - } - } - }; - } - - t.equal( - resolve.sync('./baz', opts('/foo/bar')), - path.resolve('/foo/bar/symlinked/baz.js') - ); - - t.equal( - resolve.sync('./baz.js', opts('/foo/bar')), - path.resolve('/foo/bar/symlinked/baz.js') - ); -}); - -test('readPackageSync', function (t) { - t.plan(3); - - var files = {}; - files[path.resolve('/foo/node_modules/bar/something-else.js')] = 'beep'; - files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({ - main: './baz.js' - }); - files[path.resolve('/foo/node_modules/bar/baz.js')] = 'boop'; - - var dirs = {}; - dirs[path.resolve('/foo')] = true; - dirs[path.resolve('/foo/node_modules')] = true; - - function opts(basedir, useReadPackage) { - return { - basedir: path.resolve(basedir), - isFile: function (file) { - return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); - }, - isDirectory: function (dir) { - return !!dirs[path.resolve(dir)]; - }, - readFileSync: useReadPackage ? null : function (file) { - return files[path.resolve(file)]; - }, - realpathSync: function (file) { - return file; - } - }; - } - t.test('with readFile', function (st) { - st.plan(1); - - st.equal( - resolve.sync('bar', opts('/foo')), - path.resolve('/foo/node_modules/bar/baz.js') - ); - }); - - var readPackageSync = function (readFileSync, file) { - if (file.indexOf(path.join('bar', 'package.json')) >= 0) { - return { main: './something-else.js' }; - } else { - return JSON.parse(files[path.resolve(file)]); - } - }; - - t.test('with readPackage', function (st) { - st.plan(1); - - var options = opts('/foo'); - delete options.readFileSync; - options.readPackageSync = readPackageSync; - - st.equal( - resolve.sync('bar', options), - path.resolve('/foo/node_modules/bar/something-else.js') - ); - }); - - t.test('with readFile and readPackage', function (st) { - st.plan(1); - - var options = opts('/foo'); - options.readPackageSync = readPackageSync; - st.throws( - function () { resolve.sync('bar', options); }, - TypeError, - 'errors when both readFile and readPackage are provided' - ); - }); -}); - diff --git a/node_modules/resolve/test/module_dir.js b/node_modules/resolve/test/module_dir.js deleted file mode 100644 index b50e5bb1751d6..0000000000000 --- a/node_modules/resolve/test/module_dir.js +++ /dev/null @@ -1,56 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('moduleDirectory strings', function (t) { - t.plan(4); - var dir = path.join(__dirname, 'module_dir'); - var xopts = { - basedir: dir, - moduleDirectory: 'xmodules' - }; - resolve('aaa', xopts, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, '/xmodules/aaa/index.js')); - }); - - var yopts = { - basedir: dir, - moduleDirectory: 'ymodules' - }; - resolve('aaa', yopts, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, '/ymodules/aaa/index.js')); - }); -}); - -test('moduleDirectory array', function (t) { - t.plan(6); - var dir = path.join(__dirname, 'module_dir'); - var aopts = { - basedir: dir, - moduleDirectory: ['xmodules', 'ymodules', 'zmodules'] - }; - resolve('aaa', aopts, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, '/xmodules/aaa/index.js')); - }); - - var bopts = { - basedir: dir, - moduleDirectory: ['zmodules', 'ymodules', 'xmodules'] - }; - resolve('aaa', bopts, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, '/ymodules/aaa/index.js')); - }); - - var copts = { - basedir: dir, - moduleDirectory: ['xmodules', 'ymodules', 'zmodules'] - }; - resolve('bbb', copts, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, '/zmodules/bbb/main.js')); - }); -}); diff --git a/node_modules/resolve/test/module_dir/xmodules/aaa/index.js b/node_modules/resolve/test/module_dir/xmodules/aaa/index.js deleted file mode 100644 index dd7cf7b2d022d..0000000000000 --- a/node_modules/resolve/test/module_dir/xmodules/aaa/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = function (x) { return x * 100; }; diff --git a/node_modules/resolve/test/module_dir/ymodules/aaa/index.js b/node_modules/resolve/test/module_dir/ymodules/aaa/index.js deleted file mode 100644 index ef2d4d4bf76e6..0000000000000 --- a/node_modules/resolve/test/module_dir/ymodules/aaa/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = function (x) { return x + 100; }; diff --git a/node_modules/resolve/test/module_dir/zmodules/bbb/main.js b/node_modules/resolve/test/module_dir/zmodules/bbb/main.js deleted file mode 100644 index e8ba629936a7a..0000000000000 --- a/node_modules/resolve/test/module_dir/zmodules/bbb/main.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = function (n) { return n * 111; }; diff --git a/node_modules/resolve/test/module_dir/zmodules/bbb/package.json b/node_modules/resolve/test/module_dir/zmodules/bbb/package.json deleted file mode 100644 index c13b8cf6acfd3..0000000000000 --- a/node_modules/resolve/test/module_dir/zmodules/bbb/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "main.js" -} diff --git a/node_modules/resolve/test/node-modules-paths.js b/node_modules/resolve/test/node-modules-paths.js deleted file mode 100644 index 675441db2ced7..0000000000000 --- a/node_modules/resolve/test/node-modules-paths.js +++ /dev/null @@ -1,143 +0,0 @@ -var test = require('tape'); -var path = require('path'); -var parse = path.parse || require('path-parse'); -var keys = require('object-keys'); - -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 = {}; - var parsedDirs = {}; - for (var i = 0; i < dirs.length; ++i) { - var parsed = parse(dirs[i]); - if (!foundModuleDirs[parsed.base]) { foundModuleDirs[parsed.base] = 0; } - foundModuleDirs[parsed.base] += 1; - parsedDirs[parsed.dir] = true; - uniqueDirs[dirs[i]] = true; - } - 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, 'all desired module dirs were found'); - t.equal(keys(uniqueDirs).length, dirs.length, 'all dirs provided were unique'); - - var counts = {}; - for (var j = 0; j < foundModuleDirNames.length; ++j) { - counts[foundModuleDirs[j]] = true; - } - t.equal(keys(counts).length, 1, 'all found module directories had the same count'); -}; - -test('node-modules-paths', function (t) { - t.test('no options', function (t) { - var start = path.join(__dirname, 'resolver'); - var dirs = nodeModulesPaths(start); - - verifyDirs(t, start, dirs); - - t.end(); - }); - - t.test('empty options', function (t) { - var start = path.join(__dirname, 'resolver'); - var dirs = nodeModulesPaths(start, {}); - - verifyDirs(t, start, dirs); - - t.end(); - }); - - t.test('with paths=array option', function (t) { - var start = path.join(__dirname, 'resolver'); - var paths = ['a', 'b']; - var dirs = nodeModulesPaths(start, { paths: paths }); - - verifyDirs(t, start, dirs, null, paths); - - 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'; - var dirs = nodeModulesPaths(start, { moduleDirectory: moduleDirectory }); - - verifyDirs(t, start, dirs, moduleDirectory); - - t.end(); - }); - - t.test('with 1 moduleDirectory and paths options', function (t) { - var start = path.join(__dirname, 'resolver'); - var paths = ['a', 'b']; - var moduleDirectory = 'not node modules'; - var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectory }); - - verifyDirs(t, start, dirs, moduleDirectory, paths); - - t.end(); - }); - - t.test('with 1+ moduleDirectory and paths options', function (t) { - var start = path.join(__dirname, 'resolver'); - var paths = ['a', 'b']; - var moduleDirectories = ['not node modules', 'other modules']; - var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories }); - - verifyDirs(t, start, dirs, moduleDirectories, paths); - - t.end(); - }); - - t.test('combine paths correctly on Windows', function (t) { - var start = 'C:\\Users\\username\\myProject\\src'; - var paths = []; - var moduleDirectories = ['node_modules', start]; - var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories }); - - t.equal(dirs.indexOf(path.resolve(start)) > -1, true, 'should contain start dir'); - - t.end(); - }); - - t.test('combine paths correctly on non-Windows', { skip: process.platform === 'win32' }, function (t) { - var start = '/Users/username/git/myProject/src'; - var paths = []; - var moduleDirectories = ['node_modules', '/Users/username/git/myProject/src']; - var dirs = nodeModulesPaths(start, { paths: paths, moduleDirectory: moduleDirectories }); - - t.equal(dirs.indexOf(path.resolve(start)) > -1, true, 'should contain start dir'); - - t.end(); - }); -}); diff --git a/node_modules/resolve/test/node_path.js b/node_modules/resolve/test/node_path.js deleted file mode 100644 index d06aa4eafe5b5..0000000000000 --- a/node_modules/resolve/test/node_path.js +++ /dev/null @@ -1,70 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('$NODE_PATH', function (t) { - 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, - isDirectory: isDir - }, function (err, res) { - t.error(err); - t.equal(res, path.join(__dirname, '/node_path/x/aaa/index.js'), 'aaa resolves'); - }); - - resolve('bbb', { - paths: [ - path.join(__dirname, '/node_path/x'), - path.join(__dirname, '/node_path/y') - ], - basedir: __dirname, - isDirectory: isDir - }, function (err, res) { - t.error(err); - t.equal(res, path.join(__dirname, '/node_path/y/bbb/index.js'), 'bbb resolves'); - }); - - resolve('ccc', { - paths: [ - path.join(__dirname, '/node_path/x'), - path.join(__dirname, '/node_path/y') - ], - basedir: __dirname, - isDirectory: isDir - }, function (err, res) { - 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 - resolve('tap', { - paths: [ - 'node_path' - ], - basedir: path.join(__dirname, 'node_path/x'), - isDirectory: isDir - }, function (err, res) { - var root = require('tap/package.json').main; - t.error(err); - t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap', root), 'tap resolves'); - }); -}); diff --git a/node_modules/resolve/test/node_path/x/aaa/index.js b/node_modules/resolve/test/node_path/x/aaa/index.js deleted file mode 100644 index ad70d0bb03f6f..0000000000000 --- a/node_modules/resolve/test/node_path/x/aaa/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'A'; diff --git a/node_modules/resolve/test/node_path/x/ccc/index.js b/node_modules/resolve/test/node_path/x/ccc/index.js deleted file mode 100644 index a64132e4c7e52..0000000000000 --- a/node_modules/resolve/test/node_path/x/ccc/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'C'; diff --git a/node_modules/resolve/test/node_path/y/bbb/index.js b/node_modules/resolve/test/node_path/y/bbb/index.js deleted file mode 100644 index 4d0f32e243681..0000000000000 --- a/node_modules/resolve/test/node_path/y/bbb/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'B'; diff --git a/node_modules/resolve/test/node_path/y/ccc/index.js b/node_modules/resolve/test/node_path/y/ccc/index.js deleted file mode 100644 index 793315e846687..0000000000000 --- a/node_modules/resolve/test/node_path/y/ccc/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'CY'; diff --git a/node_modules/resolve/test/nonstring.js b/node_modules/resolve/test/nonstring.js deleted file mode 100644 index ef63c40f9393d..0000000000000 --- a/node_modules/resolve/test/nonstring.js +++ /dev/null @@ -1,9 +0,0 @@ -var test = require('tape'); -var resolve = require('../'); - -test('nonstring', function (t) { - t.plan(1); - resolve(555, function (err, res, pkg) { - t.ok(err); - }); -}); diff --git a/node_modules/resolve/test/pathfilter.js b/node_modules/resolve/test/pathfilter.js deleted file mode 100644 index 16519aeae51c4..0000000000000 --- a/node_modules/resolve/test/pathfilter.js +++ /dev/null @@ -1,75 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -var resolverDir = path.join(__dirname, '/pathfilter/deep_ref'); - -var pathFilterFactory = function (t) { - return function (pkg, x, remainder) { - t.equal(pkg.version, '1.2.3'); - t.equal(x, path.join(resolverDir, 'node_modules/deep/ref')); - t.equal(remainder, 'ref'); - return 'alt'; - }; -}; - -test('#62: deep module references and the pathFilter', function (t) { - t.test('deep/ref.js', function (st) { - st.plan(3); - - resolve('deep/ref', { basedir: resolverDir }, function (err, res, pkg) { - if (err) st.fail(err); - - st.equal(pkg.version, '1.2.3'); - st.equal(res, path.join(resolverDir, 'node_modules/deep/ref.js')); - }); - - var res = resolve.sync('deep/ref', { basedir: resolverDir }); - st.equal(res, path.join(resolverDir, 'node_modules/deep/ref.js')); - }); - - t.test('deep/deeper/ref', function (st) { - st.plan(4); - - resolve( - 'deep/deeper/ref', - { basedir: resolverDir }, - function (err, res, pkg) { - if (err) t.fail(err); - st.notEqual(pkg, undefined); - st.equal(pkg.version, '1.2.3'); - st.equal(res, path.join(resolverDir, 'node_modules/deep/deeper/ref.js')); - } - ); - - var res = resolve.sync( - 'deep/deeper/ref', - { basedir: resolverDir } - ); - st.equal(res, path.join(resolverDir, 'node_modules/deep/deeper/ref.js')); - }); - - t.test('deep/ref alt', function (st) { - st.plan(8); - - var pathFilter = pathFilterFactory(st); - - var res = resolve.sync( - 'deep/ref', - { basedir: resolverDir, pathFilter: pathFilter } - ); - st.equal(res, path.join(resolverDir, 'node_modules/deep/alt.js')); - - resolve( - 'deep/ref', - { basedir: resolverDir, pathFilter: pathFilter }, - function (err, res, pkg) { - if (err) st.fail(err); - st.equal(res, path.join(resolverDir, 'node_modules/deep/alt.js')); - st.end(); - } - ); - }); - - t.end(); -}); diff --git a/node_modules/resolve/test/pathfilter/deep_ref/main.js b/node_modules/resolve/test/pathfilter/deep_ref/main.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/precedence.js b/node_modules/resolve/test/precedence.js deleted file mode 100644 index 2febb598fbc06..0000000000000 --- a/node_modules/resolve/test/precedence.js +++ /dev/null @@ -1,23 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('precedence', function (t) { - t.plan(3); - var dir = path.join(__dirname, 'precedence/aaa'); - - resolve('./', { basedir: dir }, function (err, res, pkg) { - t.ifError(err); - t.equal(res, path.join(dir, 'index.js')); - t.equal(pkg.name, 'resolve'); - }); -}); - -test('./ should not load ${dir}.js', function (t) { // eslint-disable-line no-template-curly-in-string - t.plan(1); - var dir = path.join(__dirname, 'precedence/bbb'); - - resolve('./', { basedir: dir }, function (err, res, pkg) { - t.ok(err); - }); -}); diff --git a/node_modules/resolve/test/precedence/aaa.js b/node_modules/resolve/test/precedence/aaa.js deleted file mode 100644 index b83a3e7ad98d1..0000000000000 --- a/node_modules/resolve/test/precedence/aaa.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'wtf'; diff --git a/node_modules/resolve/test/precedence/aaa/index.js b/node_modules/resolve/test/precedence/aaa/index.js deleted file mode 100644 index e0f8f6abf72f7..0000000000000 --- a/node_modules/resolve/test/precedence/aaa/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'okok'; diff --git a/node_modules/resolve/test/precedence/aaa/main.js b/node_modules/resolve/test/precedence/aaa/main.js deleted file mode 100644 index 93542a965e0ea..0000000000000 --- a/node_modules/resolve/test/precedence/aaa/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log(require('./')); diff --git a/node_modules/resolve/test/precedence/bbb.js b/node_modules/resolve/test/precedence/bbb.js deleted file mode 100644 index 2298f47fdd16d..0000000000000 --- a/node_modules/resolve/test/precedence/bbb.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = '>_<'; diff --git a/node_modules/resolve/test/precedence/bbb/main.js b/node_modules/resolve/test/precedence/bbb/main.js deleted file mode 100644 index 716b81d4bd463..0000000000000 --- a/node_modules/resolve/test/precedence/bbb/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log(require('./')); // should throw diff --git a/node_modules/resolve/test/resolver.js b/node_modules/resolve/test/resolver.js deleted file mode 100644 index aa36ee1149ba7..0000000000000 --- a/node_modules/resolve/test/resolver.js +++ /dev/null @@ -1,450 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('async foo', function (t) { - t.plan(12); - var dir = path.join(__dirname, 'resolver'); - - resolve('./foo', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo.js')); - t.equal(pkg && pkg.name, 'resolve'); - }); - - resolve('./foo.js', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo.js')); - t.equal(pkg && pkg.name, 'resolve'); - }); - - resolve('./foo', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo.js')); - t.equal(pkg && pkg.main, 'resolver'); - }); - - resolve('./foo.js', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo.js')); - t.equal(pkg.main, 'resolver'); - }); - - resolve('./foo', { basedir: dir, filename: path.join(dir, 'baz.js') }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo.js')); - }); - - resolve('foo', { basedir: dir }, function (err) { - t.equal(err.message, "Cannot find module 'foo' from '" + path.resolve(dir) + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); - - // Test that filename is reported as the "from" value when passed. - resolve('foo', { basedir: dir, filename: path.join(dir, 'baz.js') }, function (err) { - t.equal(err.message, "Cannot find module 'foo' from '" + path.join(dir, 'baz.js') + "'"); - }); -}); - -test('bar', function (t) { - t.plan(6); - var dir = path.join(__dirname, 'resolver'); - - resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js')); - t.equal(pkg, undefined); - }); - - resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js')); - t.equal(pkg, undefined); - }); - - resolve('foo', { basedir: dir + '/bar', 'package': { main: 'bar' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js')); - t.equal(pkg.main, 'bar'); - }); -}); - -test('baz', function (t) { - t.plan(4); - var dir = path.join(__dirname, 'resolver'); - - resolve('./baz', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'baz/quux.js')); - t.equal(pkg.main, 'quux.js'); - }); - - resolve('./baz', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'baz/quux.js')); - t.equal(pkg.main, 'quux.js'); - }); -}); - -test('biz', function (t) { - t.plan(24); - var dir = path.join(__dirname, 'resolver/biz/node_modules'); - - resolve('./grux', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'grux/index.js')); - t.equal(pkg, undefined); - }); - - resolve('./grux', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'grux/index.js')); - t.equal(pkg.main, 'biz'); - }); - - resolve('./garply', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'garply/lib/index.js')); - t.equal(pkg.main, './lib'); - }); - - resolve('./garply', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'garply/lib/index.js')); - t.equal(pkg.main, './lib'); - }); - - resolve('tiv', { basedir: dir + '/grux' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'tiv/index.js')); - t.equal(pkg, undefined); - }); - - resolve('tiv', { basedir: dir + '/grux', 'package': { main: 'grux' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'tiv/index.js')); - t.equal(pkg.main, 'grux'); - }); - - resolve('tiv', { basedir: dir + '/garply' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'tiv/index.js')); - t.equal(pkg, undefined); - }); - - resolve('tiv', { basedir: dir + '/garply', 'package': { main: './lib' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'tiv/index.js')); - t.equal(pkg.main, './lib'); - }); - - resolve('grux', { basedir: dir + '/tiv' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'grux/index.js')); - t.equal(pkg, undefined); - }); - - resolve('grux', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'grux/index.js')); - t.equal(pkg.main, 'tiv'); - }); - - resolve('garply', { basedir: dir + '/tiv' }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'garply/lib/index.js')); - t.equal(pkg.main, './lib'); - }); - - resolve('garply', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'garply/lib/index.js')); - t.equal(pkg.main, './lib'); - }); -}); - -test('quux', function (t) { - t.plan(2); - var dir = path.join(__dirname, 'resolver/quux'); - - resolve('./foo', { basedir: dir, 'package': { main: 'quux' } }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'foo/index.js')); - t.equal(pkg.main, 'quux'); - }); -}); - -test('normalize', function (t) { - t.plan(2); - var dir = path.join(__dirname, 'resolver/biz/node_modules/grux'); - - resolve('../grux', { basedir: dir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'index.js')); - t.equal(pkg, undefined); - }); -}); - -test('cup', function (t) { - t.plan(5); - var dir = path.join(__dirname, 'resolver'); - - resolve('./cup', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'cup.coffee')); - }); - - resolve('./cup.coffee', { basedir: dir }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'cup.coffee')); - }); - - resolve('./cup', { basedir: dir, extensions: ['.js'] }, function (err, res) { - t.equal(err.message, "Cannot find module './cup' from '" + path.resolve(dir) + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); - - // Test that filename is reported as the "from" value when passed. - resolve('./cup', { basedir: dir, extensions: ['.js'], filename: path.join(dir, 'cupboard.js') }, function (err, res) { - t.equal(err.message, "Cannot find module './cup' from '" + path.join(dir, 'cupboard.js') + "'"); - }); -}); - -test('mug', function (t) { - t.plan(3); - var dir = path.join(__dirname, 'resolver'); - - resolve('./mug', { basedir: dir }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'mug.js')); - }); - - resolve('./mug', { basedir: dir, extensions: ['.coffee', '.js'] }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(dir, '/mug.coffee')); - }); - - resolve('./mug', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) { - t.equal(res, path.join(dir, '/mug.js')); - }); -}); - -test('other path', function (t) { - t.plan(6); - var resolverDir = path.join(__dirname, 'resolver'); - var dir = path.join(resolverDir, 'bar'); - var otherDir = path.join(resolverDir, 'other_path'); - - resolve('root', { basedir: dir, paths: [otherDir] }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(resolverDir, 'other_path/root.js')); - }); - - resolve('lib/other-lib', { basedir: dir, paths: [otherDir] }, function (err, res) { - if (err) t.fail(err); - t.equal(res, path.join(resolverDir, 'other_path/lib/other-lib.js')); - }); - - resolve('root', { basedir: dir }, function (err, res) { - t.equal(err.message, "Cannot find module 'root' from '" + path.resolve(dir) + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); - - resolve('zzz', { basedir: dir, paths: [otherDir] }, function (err, res) { - t.equal(err.message, "Cannot find module 'zzz' from '" + path.resolve(dir) + "'"); - t.equal(err.code, 'MODULE_NOT_FOUND'); - }); -}); - -test('path iterator', function (t) { - t.plan(2); - - var resolverDir = path.join(__dirname, 'resolver'); - - var exactIterator = function (x, start, getPackageCandidates, opts) { - return [path.join(resolverDir, x)]; - }; - - resolve('baz', { packageIterator: exactIterator }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(resolverDir, 'baz/quux.js')); - t.equal(pkg && pkg.name, 'baz'); - }); -}); - -test('incorrect main', function (t) { - t.plan(1); - - var resolverDir = path.join(__dirname, 'resolver'); - var dir = path.join(resolverDir, 'incorrect_main'); - - resolve('./incorrect_main', { basedir: resolverDir }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'index.js')); - }); -}); - -test('without basedir', function (t) { - t.plan(1); - - var dir = path.join(__dirname, 'resolver/without_basedir'); - var tester = require(path.join(dir, 'main.js')); - - tester(t, function (err, res, pkg) { - if (err) { - t.fail(err); - } else { - t.equal(res, path.join(dir, 'node_modules/mymodule.js')); - } - }); -}); - -test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) { - t.plan(2); - - var dir = path.join(__dirname, 'resolver'); - - resolve('./foo', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'same_names/foo.js')); - }); - - resolve('./foo/', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'same_names/foo/index.js')); - }); -}); - -test('#211 - incorrectly resolves module-paths like "." when from inside a folder with a sibling file of the same name', function (t) { - t.plan(2); - - var dir = path.join(__dirname, 'resolver'); - - resolve('./', { basedir: path.join(dir, 'same_names/foo') }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'same_names/foo/index.js')); - }); - - resolve('.', { basedir: path.join(dir, 'same_names/foo') }, function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'same_names/foo/index.js')); - }); -}); - -test('async: #121 - treating an existing file as a dir when no basedir', function (t) { - var testFile = path.basename(__filename); - - t.test('sanity check', function (st) { - st.plan(1); - resolve('./' + testFile, function (err, res, pkg) { - if (err) t.fail(err); - st.equal(res, __filename, 'sanity check'); - }); - }); - - t.test('with a fake directory', function (st) { - st.plan(4); - - resolve('./' + testFile + '/blah', function (err, res, pkg) { - st.ok(err, 'there is an error'); - st.notOk(res, 'no result'); - - st.equal(err && err.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve'); - st.equal( - err && err.message, - 'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'', - 'can not find nonexistent module' - ); - st.end(); - }); - }); - - t.end(); -}); - -test('async dot main', function (t) { - var start = new Date(); - t.plan(3); - resolve('./resolver/dot_main', function (err, ret) { - t.notOk(err); - t.equal(ret, path.join(__dirname, 'resolver/dot_main/index.js')); - t.ok(new Date() - start < 50, 'resolve.sync timedout'); - t.end(); - }); -}); - -test('async dot slash main', function (t) { - var start = new Date(); - t.plan(3); - resolve('./resolver/dot_slash_main', function (err, ret) { - t.notOk(err); - t.equal(ret, path.join(__dirname, 'resolver/dot_slash_main/index.js')); - t.ok(new Date() - start < 50, 'resolve.sync timedout'); - t.end(); - }); -}); - -test('not a directory', function (t) { - t.plan(6); - var path = './foo'; - resolve(path, { basedir: __filename }, function (err, res, pkg) { - t.ok(err, 'a non-directory errors'); - t.equal(arguments.length, 1); - t.equal(res, undefined); - t.equal(pkg, undefined); - - 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'); - }); -}); - -test('browser field in package.json', function (t) { - t.plan(3); - - var dir = path.join(__dirname, 'resolver'); - resolve( - './browser_field', - { - basedir: dir, - packageFilter: function packageFilter(pkg) { - if (pkg.browser) { - pkg.main = pkg.browser; // eslint-disable-line no-param-reassign - delete pkg.browser; // eslint-disable-line no-param-reassign - } - return pkg; - } - }, - function (err, res, pkg) { - if (err) t.fail(err); - t.equal(res, path.join(dir, 'browser_field', 'b.js')); - t.equal(pkg && pkg.main, 'b'); - t.equal(pkg && pkg.browser, undefined); - } - ); -}); diff --git a/node_modules/resolve/test/resolver/baz/doom.js b/node_modules/resolve/test/resolver/baz/doom.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/baz/package.json b/node_modules/resolve/test/resolver/baz/package.json deleted file mode 100644 index 2f77720b8672a..0000000000000 --- a/node_modules/resolve/test/resolver/baz/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "baz", - "main": "quux.js" -} diff --git a/node_modules/resolve/test/resolver/baz/quux.js b/node_modules/resolve/test/resolver/baz/quux.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/baz/quux.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/browser_field/a.js b/node_modules/resolve/test/resolver/browser_field/a.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/browser_field/b.js b/node_modules/resolve/test/resolver/browser_field/b.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/browser_field/package.json b/node_modules/resolve/test/resolver/browser_field/package.json deleted file mode 100644 index bf406f0830f8a..0000000000000 --- a/node_modules/resolve/test/resolver/browser_field/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "browser_field", - "main": "a", - "browser": "b" -} diff --git a/node_modules/resolve/test/resolver/cup.coffee b/node_modules/resolve/test/resolver/cup.coffee deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/node_modules/resolve/test/resolver/cup.coffee +++ /dev/null @@ -1 +0,0 @@ - diff --git a/node_modules/resolve/test/resolver/dot_main/index.js b/node_modules/resolve/test/resolver/dot_main/index.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/dot_main/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/dot_main/package.json b/node_modules/resolve/test/resolver/dot_main/package.json deleted file mode 100644 index d7f4fc8079f60..0000000000000 --- a/node_modules/resolve/test/resolver/dot_main/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "." -} diff --git a/node_modules/resolve/test/resolver/dot_slash_main/index.js b/node_modules/resolve/test/resolver/dot_slash_main/index.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/dot_slash_main/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/dot_slash_main/package.json b/node_modules/resolve/test/resolver/dot_slash_main/package.json deleted file mode 100644 index f51287b9d1e73..0000000000000 --- a/node_modules/resolve/test/resolver/dot_slash_main/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "./" -} diff --git a/node_modules/resolve/test/resolver/foo.js b/node_modules/resolve/test/resolver/foo.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/foo.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/incorrect_main/index.js b/node_modules/resolve/test/resolver/incorrect_main/index.js deleted file mode 100644 index bc1fb0a6f4ede..0000000000000 --- a/node_modules/resolve/test/resolver/incorrect_main/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// this is the actual main file 'index.js', not 'wrong.js' like the package.json would indicate -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/incorrect_main/package.json b/node_modules/resolve/test/resolver/incorrect_main/package.json deleted file mode 100644 index b7188041763f8..0000000000000 --- a/node_modules/resolve/test/resolver/incorrect_main/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "wrong.js" -} diff --git a/node_modules/resolve/test/resolver/invalid_main/package.json b/node_modules/resolve/test/resolver/invalid_main/package.json deleted file mode 100644 index 0cf8279950c38..0000000000000 --- a/node_modules/resolve/test/resolver/invalid_main/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "invalid main", - "main": [ - "why is this a thing", - "srsly omg wtf" - ] -} diff --git a/node_modules/resolve/test/resolver/mug.coffee b/node_modules/resolve/test/resolver/mug.coffee deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/mug.js b/node_modules/resolve/test/resolver/mug.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/multirepo/lerna.json b/node_modules/resolve/test/resolver/multirepo/lerna.json deleted file mode 100644 index d6707ca0cd64d..0000000000000 --- a/node_modules/resolve/test/resolver/multirepo/lerna.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "packages": [ - "packages/*" - ], - "version": "0.0.0" -} diff --git a/node_modules/resolve/test/resolver/multirepo/package.json b/node_modules/resolve/test/resolver/multirepo/package.json deleted file mode 100644 index 8508f9d2c4a2d..0000000000000 --- a/node_modules/resolve/test/resolver/multirepo/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "monorepo-symlink-test", - "private": true, - "version": "0.0.0", - "description": "", - "main": "index.js", - "scripts": { - "postinstall": "lerna bootstrap", - "test": "node packages/package-a" - }, - "author": "", - "license": "MIT", - "dependencies": { - "jquery": "^3.3.1", - "resolve": "../../../" - }, - "devDependencies": { - "lerna": "^3.4.3" - } -} diff --git a/node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js b/node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js deleted file mode 100644 index 8875a32df0ffc..0000000000000 --- a/node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -var assert = require('assert'); -var path = require('path'); -var resolve = require('resolve'); - -var basedir = __dirname + '/node_modules/@my-scope/package-b'; - -var expected = path.join(__dirname, '../../node_modules/jquery/dist/jquery.js'); - -/* - * preserveSymlinks === false - * will search NPM package from - * - packages/package-b/node_modules - * - packages/node_modules - * - node_modules - */ -assert.equal(resolve.sync('jquery', { basedir: basedir, preserveSymlinks: false }), expected); -assert.equal(resolve.sync('../../node_modules/jquery', { basedir: basedir, preserveSymlinks: false }), expected); - -/* - * preserveSymlinks === true - * will search NPM package from - * - packages/package-a/node_modules/@my-scope/packages/package-b/node_modules - * - packages/package-a/node_modules/@my-scope/packages/node_modules - * - packages/package-a/node_modules/@my-scope/node_modules - * - packages/package-a/node_modules/node_modules - * - packages/package-a/node_modules - * - packages/node_modules - * - node_modules - */ -assert.equal(resolve.sync('jquery', { basedir: basedir, preserveSymlinks: true }), expected); -assert.equal(resolve.sync('../../../../../node_modules/jquery', { basedir: basedir, preserveSymlinks: true }), expected); - -console.log(' * all monorepo paths successfully resolved through symlinks'); diff --git a/node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json b/node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json deleted file mode 100644 index 204de51e05878..0000000000000 --- a/node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@my-scope/package-a", - "version": "0.0.0", - "private": true, - "description": "", - "license": "MIT", - "main": "index.js", - "scripts": { - "test": "echo \"Error: run tests from root\" && exit 1" - }, - "dependencies": { - "@my-scope/package-b": "^0.0.0" - } -} diff --git a/node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js b/node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json b/node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json deleted file mode 100644 index f57c3b5f5e454..0000000000000 --- a/node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@my-scope/package-b", - "private": true, - "version": "0.0.0", - "description": "", - "license": "MIT", - "main": "index.js", - "scripts": { - "test": "echo \"Error: run tests from root\" && exit 1" - }, - "dependencies": { - "@my-scope/package-a": "^0.0.0" - } -} diff --git a/node_modules/resolve/test/resolver/nested_symlinks/mylib/async.js b/node_modules/resolve/test/resolver/nested_symlinks/mylib/async.js deleted file mode 100644 index 9b4846a82a77b..0000000000000 --- a/node_modules/resolve/test/resolver/nested_symlinks/mylib/async.js +++ /dev/null @@ -1,26 +0,0 @@ -var a = require.resolve('buffer/').replace(process.cwd(), '$CWD'); -var b; -var c; - -var test = function test() { - console.log(a, ': require.resolve, preserveSymlinks ' + (process.execArgv.indexOf('preserve-symlinks') > -1 ? 'true' : 'false')); - console.log(b, ': preserveSymlinks true'); - console.log(c, ': preserveSymlinks false'); - - if (a !== b && a !== c) { - throw 'async: no match'; - } - console.log('async: success! a matched either b or c\n'); -}; - -require('resolve')('buffer/', { preserveSymlinks: true }, function (err, result) { - if (err) { throw err; } - b = result.replace(process.cwd(), '$CWD'); - if (b && c) { test(); } -}); -require('resolve')('buffer/', { preserveSymlinks: false }, function (err, result) { - if (err) { throw err; } - c = result.replace(process.cwd(), '$CWD'); - if (b && c) { test(); } -}); - diff --git a/node_modules/resolve/test/resolver/nested_symlinks/mylib/package.json b/node_modules/resolve/test/resolver/nested_symlinks/mylib/package.json deleted file mode 100644 index acfe9e9517720..0000000000000 --- a/node_modules/resolve/test/resolver/nested_symlinks/mylib/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "mylib", - "version": "0.0.0", - "description": "", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "buffer": "*" - } -} diff --git a/node_modules/resolve/test/resolver/nested_symlinks/mylib/sync.js b/node_modules/resolve/test/resolver/nested_symlinks/mylib/sync.js deleted file mode 100644 index 3283efc2ec81f..0000000000000 --- a/node_modules/resolve/test/resolver/nested_symlinks/mylib/sync.js +++ /dev/null @@ -1,12 +0,0 @@ -var a = require.resolve('buffer/').replace(process.cwd(), '$CWD'); -var b = require('resolve').sync('buffer/', { preserveSymlinks: true }).replace(process.cwd(), '$CWD'); -var c = require('resolve').sync('buffer/', { preserveSymlinks: false }).replace(process.cwd(), '$CWD'); - -console.log(a, ': require.resolve, preserveSymlinks ' + (process.execArgv.indexOf('preserve-symlinks') > -1 ? 'true' : 'false')); -console.log(b, ': preserveSymlinks true'); -console.log(c, ': preserveSymlinks false'); - -if (a !== b && a !== c) { - throw 'sync: no match'; -} -console.log('sync: success! a matched either b or c\n'); diff --git a/node_modules/resolve/test/resolver/other_path/lib/other-lib.js b/node_modules/resolve/test/resolver/other_path/lib/other-lib.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/other_path/root.js b/node_modules/resolve/test/resolver/other_path/root.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/quux/foo/index.js b/node_modules/resolve/test/resolver/quux/foo/index.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/quux/foo/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/same_names/foo.js b/node_modules/resolve/test/resolver/same_names/foo.js deleted file mode 100644 index 888cae37af95c..0000000000000 --- a/node_modules/resolve/test/resolver/same_names/foo.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 42; diff --git a/node_modules/resolve/test/resolver/same_names/foo/index.js b/node_modules/resolve/test/resolver/same_names/foo/index.js deleted file mode 100644 index bd816eaba4ca3..0000000000000 --- a/node_modules/resolve/test/resolver/same_names/foo/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/node_modules/resolve/test/resolver/symlinked/_/node_modules/foo.js b/node_modules/resolve/test/resolver/symlinked/_/node_modules/foo.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/resolver/symlinked/package/bar.js b/node_modules/resolve/test/resolver/symlinked/package/bar.js deleted file mode 100644 index cb1c2c01e753b..0000000000000 --- a/node_modules/resolve/test/resolver/symlinked/package/bar.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'bar'; diff --git a/node_modules/resolve/test/resolver/symlinked/package/package.json b/node_modules/resolve/test/resolver/symlinked/package/package.json deleted file mode 100644 index 8e1b585914a7b..0000000000000 --- a/node_modules/resolve/test/resolver/symlinked/package/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "bar.js" -} \ No newline at end of file diff --git a/node_modules/resolve/test/resolver/without_basedir/main.js b/node_modules/resolve/test/resolver/without_basedir/main.js deleted file mode 100644 index 5b31975be69da..0000000000000 --- a/node_modules/resolve/test/resolver/without_basedir/main.js +++ /dev/null @@ -1,5 +0,0 @@ -var resolve = require('../../../'); - -module.exports = function (t, cb) { - resolve('mymodule', null, cb); -}; diff --git a/node_modules/resolve/test/resolver_sync.js b/node_modules/resolve/test/resolver_sync.js deleted file mode 100644 index 3082c96e58b74..0000000000000 --- a/node_modules/resolve/test/resolver_sync.js +++ /dev/null @@ -1,358 +0,0 @@ -var path = require('path'); -var test = require('tape'); -var resolve = require('../'); - -test('foo', function (t) { - var dir = path.join(__dirname, 'resolver'); - - t.equal( - resolve.sync('./foo', { basedir: dir }), - path.join(dir, 'foo.js') - ); - - t.equal( - resolve.sync('./foo.js', { basedir: dir }), - path.join(dir, 'foo.js') - ); - - t.equal( - resolve.sync('./foo.js', { basedir: dir, filename: path.join(dir, 'bar.js') }), - path.join(dir, 'foo.js') - ); - - t.throws(function () { - resolve.sync('foo', { basedir: dir }); - }); - - // Test that filename is reported as the "from" value when passed. - t.throws( - function () { - resolve.sync('foo', { basedir: dir, filename: path.join(dir, 'bar.js') }); - }, - { - name: 'Error', - message: "Cannot find module 'foo' from '" + path.join(dir, 'bar.js') + "'" - } - ); - - t.end(); -}); - -test('bar', function (t) { - var dir = path.join(__dirname, 'resolver'); - - t.equal( - resolve.sync('foo', { basedir: path.join(dir, 'bar') }), - path.join(dir, 'bar/node_modules/foo/index.js') - ); - t.end(); -}); - -test('baz', function (t) { - var dir = path.join(__dirname, 'resolver'); - - t.equal( - resolve.sync('./baz', { basedir: dir }), - path.join(dir, 'baz/quux.js') - ); - t.end(); -}); - -test('biz', function (t) { - var dir = path.join(__dirname, 'resolver/biz/node_modules'); - t.equal( - resolve.sync('./grux', { basedir: dir }), - path.join(dir, 'grux/index.js') - ); - - t.equal( - resolve.sync('tiv', { basedir: path.join(dir, 'grux') }), - path.join(dir, 'tiv/index.js') - ); - - t.equal( - resolve.sync('grux', { basedir: path.join(dir, 'tiv') }), - path.join(dir, 'grux/index.js') - ); - t.end(); -}); - -test('normalize', function (t) { - var dir = path.join(__dirname, 'resolver/biz/node_modules/grux'); - t.equal( - resolve.sync('../grux', { basedir: dir }), - path.join(dir, 'index.js') - ); - t.end(); -}); - -test('cup', function (t) { - var dir = path.join(__dirname, 'resolver'); - t.equal( - resolve.sync('./cup', { - basedir: dir, - extensions: ['.js', '.coffee'] - }), - path.join(dir, 'cup.coffee') - ); - - t.equal( - resolve.sync('./cup.coffee', { basedir: dir }), - path.join(dir, 'cup.coffee') - ); - - t.throws(function () { - resolve.sync('./cup', { - basedir: dir, - extensions: ['.js'] - }); - }); - - t.end(); -}); - -test('mug', function (t) { - var dir = path.join(__dirname, 'resolver'); - t.equal( - resolve.sync('./mug', { basedir: dir }), - path.join(dir, 'mug.js') - ); - - t.equal( - resolve.sync('./mug', { - basedir: dir, - extensions: ['.coffee', '.js'] - }), - path.join(dir, 'mug.coffee') - ); - - t.equal( - resolve.sync('./mug', { - basedir: dir, - extensions: ['.js', '.coffee'] - }), - path.join(dir, 'mug.js') - ); - - t.end(); -}); - -test('other path', function (t) { - var resolverDir = path.join(__dirname, 'resolver'); - var dir = path.join(resolverDir, 'bar'); - var otherDir = path.join(resolverDir, 'other_path'); - - t.equal( - resolve.sync('root', { - basedir: dir, - paths: [otherDir] - }), - path.join(resolverDir, 'other_path/root.js') - ); - - t.equal( - resolve.sync('lib/other-lib', { - basedir: dir, - paths: [otherDir] - }), - path.join(resolverDir, 'other_path/lib/other-lib.js') - ); - - t.throws(function () { - resolve.sync('root', { basedir: dir }); - }); - - t.throws(function () { - resolve.sync('zzz', { - basedir: dir, - paths: [otherDir] - }); - }); - - t.end(); -}); - -test('path iterator', function (t) { - var resolverDir = path.join(__dirname, 'resolver'); - - var exactIterator = function (x, start, getPackageCandidates, opts) { - return [path.join(resolverDir, x)]; - }; - - t.equal( - resolve.sync('baz', { packageIterator: exactIterator }), - path.join(resolverDir, 'baz/quux.js') - ); - - t.end(); -}); - -test('incorrect main', function (t) { - var resolverDir = path.join(__dirname, 'resolver'); - var dir = path.join(resolverDir, 'incorrect_main'); - - t.equal( - resolve.sync('./incorrect_main', { basedir: resolverDir }), - path.join(dir, 'index.js') - ); - - t.end(); -}); - -var stubStatSync = function stubStatSync(fn) { - var fs = require('fs'); - var statSync = fs.statSync; - try { - fs.statSync = function () { - throw new EvalError('Unknown Error'); - }; - return fn(); - } finally { - fs.statSync = statSync; - } -}; - -test('#79 - re-throw non ENOENT errors from stat', function (t) { - var dir = path.join(__dirname, 'resolver'); - - stubStatSync(function () { - t.throws(function () { - resolve.sync('foo', { basedir: dir }); - }, /Unknown Error/); - }); - - t.end(); -}); - -test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) { - var dir = path.join(__dirname, 'resolver'); - - t.equal( - resolve.sync('./foo', { basedir: path.join(dir, 'same_names') }), - path.join(dir, 'same_names/foo.js') - ); - t.equal( - resolve.sync('./foo/', { basedir: path.join(dir, 'same_names') }), - path.join(dir, 'same_names/foo/index.js') - ); - t.end(); -}); - -test('#211 - incorrectly resolves module-paths like "." when from inside a folder with a sibling file of the same name', function (t) { - var dir = path.join(__dirname, 'resolver'); - - t.equal( - resolve.sync('./', { basedir: path.join(dir, 'same_names/foo') }), - path.join(dir, 'same_names/foo/index.js') - ); - t.equal( - resolve.sync('.', { basedir: path.join(dir, 'same_names/foo') }), - path.join(dir, 'same_names/foo/index.js') - ); - t.end(); -}); - -test('sync: #121 - treating an existing file as a dir when no basedir', function (t) { - var testFile = path.basename(__filename); - - t.test('sanity check', function (st) { - st.equal( - resolve.sync('./' + testFile), - __filename, - 'sanity check' - ); - st.end(); - }); - - t.test('with a fake directory', function (st) { - function run() { return resolve.sync('./' + testFile + '/blah'); } - - st.throws(run, 'throws an error'); - - try { - run(); - } catch (e) { - st.equal(e.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve'); - st.equal( - e.message, - 'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'', - 'can not find nonexistent module' - ); - } - - st.end(); - }); - - t.end(); -}); - -test('sync dot main', function (t) { - var start = new Date(); - t.equal(resolve.sync('./resolver/dot_main'), path.join(__dirname, 'resolver/dot_main/index.js')); - t.ok(new Date() - start < 50, 'resolve.sync timedout'); - t.end(); -}); - -test('sync dot slash main', function (t) { - var start = new Date(); - t.equal(resolve.sync('./resolver/dot_slash_main'), path.join(__dirname, 'resolver/dot_slash_main/index.js')); - t.ok(new Date() - start < 50, 'resolve.sync timedout'); - t.end(); -}); - -test('not a directory', function (t) { - var path = './foo'; - try { - resolve.sync(path, { basedir: __filename }); - t.fail(); - } 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(); -}); - -test('browser field in package.json', function (t) { - var dir = path.join(__dirname, 'resolver'); - var res = resolve.sync('./browser_field', { - basedir: dir, - packageFilter: function packageFilter(pkg) { - if (pkg.browser) { - pkg.main = pkg.browser; // eslint-disable-line no-param-reassign - delete pkg.browser; // eslint-disable-line no-param-reassign - } - return pkg; - } - }); - t.equal(res, path.join(dir, 'browser_field', 'b.js')); - t.end(); -}); diff --git a/node_modules/resolve/test/shadowed_core.js b/node_modules/resolve/test/shadowed_core.js deleted file mode 100644 index 3a5f4fcff728f..0000000000000 --- a/node_modules/resolve/test/shadowed_core.js +++ /dev/null @@ -1,54 +0,0 @@ -var test = require('tape'); -var resolve = require('../'); -var path = require('path'); - -test('shadowed core modules still return core module', function (t) { - t.plan(2); - - resolve('util', { basedir: path.join(__dirname, 'shadowed_core') }, function (err, res) { - t.ifError(err); - t.equal(res, 'util'); - }); -}); - -test('shadowed core modules still return core module [sync]', function (t) { - t.plan(1); - - var res = resolve.sync('util', { basedir: path.join(__dirname, 'shadowed_core') }); - - t.equal(res, 'util'); -}); - -test('shadowed core modules return shadow when appending `/`', function (t) { - t.plan(2); - - resolve('util/', { basedir: path.join(__dirname, 'shadowed_core') }, function (err, res) { - t.ifError(err); - t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js')); - }); -}); - -test('shadowed core modules return shadow when appending `/` [sync]', function (t) { - t.plan(1); - - var res = resolve.sync('util/', { basedir: path.join(__dirname, 'shadowed_core') }); - - t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js')); -}); - -test('shadowed core modules return shadow with `includeCoreModules: false`', function (t) { - t.plan(2); - - resolve('util', { basedir: path.join(__dirname, 'shadowed_core'), includeCoreModules: false }, function (err, res) { - t.ifError(err); - t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js')); - }); -}); - -test('shadowed core modules return shadow with `includeCoreModules: false` [sync]', function (t) { - t.plan(1); - - var res = resolve.sync('util', { basedir: path.join(__dirname, 'shadowed_core'), includeCoreModules: false }); - - t.equal(res, path.join(__dirname, 'shadowed_core/node_modules/util/index.js')); -}); diff --git a/node_modules/resolve/test/shadowed_core/node_modules/util/index.js b/node_modules/resolve/test/shadowed_core/node_modules/util/index.js deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/node_modules/resolve/test/subdirs.js b/node_modules/resolve/test/subdirs.js deleted file mode 100644 index b7b8450a9ef23..0000000000000 --- a/node_modules/resolve/test/subdirs.js +++ /dev/null @@ -1,13 +0,0 @@ -var test = require('tape'); -var resolve = require('../'); -var path = require('path'); - -test('subdirs', function (t) { - t.plan(2); - - var dir = path.join(__dirname, '/subdirs'); - resolve('a/b/c/x.json', { basedir: dir }, function (err, res) { - t.ifError(err); - t.equal(res, path.join(dir, 'node_modules/a/b/c/x.json')); - }); -}); diff --git a/node_modules/resolve/test/symlinks.js b/node_modules/resolve/test/symlinks.js deleted file mode 100644 index 35f881afb8c7e..0000000000000 --- a/node_modules/resolve/test/symlinks.js +++ /dev/null @@ -1,176 +0,0 @@ -var path = require('path'); -var fs = require('fs'); -var test = require('tape'); -var map = require('array.prototype.map'); -var resolve = require('../'); - -var symlinkDir = path.join(__dirname, 'resolver', 'symlinked', 'symlink'); -var packageDir = path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'package'); -var modADir = path.join(__dirname, 'symlinks', 'source', 'node_modules', 'mod-a'); -var symlinkModADir = path.join(__dirname, 'symlinks', 'dest', 'node_modules', 'mod-a'); -try { - fs.unlinkSync(symlinkDir); -} catch (err) {} -try { - fs.unlinkSync(packageDir); -} catch (err) {} -try { - fs.unlinkSync(modADir); -} catch (err) {} -try { - fs.unlinkSync(symlinkModADir); -} catch (err) {} - -try { - fs.symlinkSync('./_/symlink_target', symlinkDir, 'dir'); -} catch (err) { - // if fails then it is probably on Windows and lets try to create a junction - fs.symlinkSync(path.join(__dirname, 'resolver', 'symlinked', '_', 'symlink_target') + '\\', symlinkDir, 'junction'); -} -try { - fs.symlinkSync('../../package', packageDir, 'dir'); -} catch (err) { - // if fails then it is probably on Windows and lets try to create a junction - fs.symlinkSync(path.join(__dirname, '..', '..', 'package') + '\\', packageDir, 'junction'); -} -try { - fs.symlinkSync('../../source/node_modules/mod-a', symlinkModADir, 'dir'); -} catch (err) { - // if fails then it is probably on Windows and lets try to create a junction - fs.symlinkSync(path.join(__dirname, '..', '..', 'source', 'node_modules', 'mod-a') + '\\', symlinkModADir, 'junction'); -} - -test('symlink', function (t) { - t.plan(2); - - resolve('foo', { basedir: symlinkDir, preserveSymlinks: false }, function (err, res, pkg) { - t.error(err); - t.equal(res, path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js')); - }); -}); - -test('sync symlink when preserveSymlinks = true', function (t) { - t.plan(4); - - resolve('foo', { basedir: symlinkDir }, function (err, res, pkg) { - t.ok(err, 'there is an error'); - t.notOk(res, 'no result'); - - t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve'); - t.equal( - err && err.message, - 'Cannot find module \'foo\' from \'' + symlinkDir + '\'', - 'can not find nonexistent module' - ); - }); -}); - -test('sync symlink', function (t) { - var start = new Date(); - t.doesNotThrow(function () { - t.equal( - resolve.sync('foo', { basedir: symlinkDir, preserveSymlinks: false }), - path.join(__dirname, 'resolver', 'symlinked', '_', 'node_modules', 'foo.js') - ); - }); - t.ok(new Date() - start < 50, 'resolve.sync timedout'); - t.end(); -}); - -test('sync symlink when preserveSymlinks = true', function (t) { - t.throws(function () { - resolve.sync('foo', { basedir: symlinkDir }); - }, /Cannot find module 'foo'/); - t.end(); -}); - -test('sync symlink from node_modules to other dir when preserveSymlinks = false', function (t) { - var basedir = path.join(__dirname, 'resolver', 'symlinked', '_'); - var fn = resolve.sync('package', { basedir: basedir, preserveSymlinks: false }); - - t.equal(fn, path.resolve(__dirname, 'resolver/symlinked/package/bar.js')); - t.end(); -}); - -test('async symlink from node_modules to other dir when preserveSymlinks = false', function (t) { - t.plan(2); - var basedir = path.join(__dirname, 'resolver', 'symlinked', '_'); - resolve('package', { basedir: basedir, preserveSymlinks: false }, function (err, result) { - t.notOk(err, 'no error'); - t.equal(result, path.resolve(__dirname, 'resolver/symlinked/package/bar.js')); - }); -}); - -test('packageFilter', function (t) { - function relative(x) { - return path.relative(__dirname, x); - } - - function testPackageFilter(preserveSymlinks) { - return function (st) { - st.plan('is 1.x' ? 3 : 5); // eslint-disable-line no-constant-condition - - var destMain = 'symlinks/dest/node_modules/mod-a/index.js'; - var destPkg = 'symlinks/dest/node_modules/mod-a/package.json'; - var sourceMain = 'symlinks/source/node_modules/mod-a/index.js'; - var sourcePkg = 'symlinks/source/node_modules/mod-a/package.json'; - var destDir = path.join(__dirname, 'symlinks', 'dest'); - - /* eslint multiline-comment-style: 0 */ - /* v2.x will restore these tests - var packageFilterPath = []; - var actualPath = resolve.sync('mod-a', { - basedir: destDir, - preserveSymlinks: preserveSymlinks, - packageFilter: function (pkg, pkgfile, dir) { - packageFilterPath.push(pkgfile); - } - }); - st.equal( - relative(actualPath), - path.normalize(preserveSymlinks ? destMain : sourceMain), - 'sync: actual path is correct' - ); - st.deepEqual( - map(packageFilterPath, relative), - map(preserveSymlinks ? [destPkg, destPkg] : [sourcePkg, sourcePkg], path.normalize), - 'sync: packageFilter pkgfile arg is correct' - ); - */ - - var asyncPackageFilterPath = []; - resolve( - 'mod-a', - { - basedir: destDir, - preserveSymlinks: preserveSymlinks, - packageFilter: function (pkg, pkgfile) { - asyncPackageFilterPath.push(pkgfile); - } - }, - function (err, actualPath) { - st.error(err, 'no error'); - st.equal( - relative(actualPath), - path.normalize(preserveSymlinks ? destMain : sourceMain), - 'async: actual path is correct' - ); - st.deepEqual( - map(asyncPackageFilterPath, relative), - map( - preserveSymlinks ? [destPkg, destPkg, destPkg] : [sourcePkg, sourcePkg, sourcePkg], - path.normalize - ), - 'async: packageFilter pkgfile arg is correct' - ); - } - ); - }; - } - - t.test('preserveSymlinks: false', testPackageFilter(false)); - - t.test('preserveSymlinks: true', testPackageFilter(true)); - - t.end(); -});