nyc 13.2.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/commands/report.js +40 -0
- package/lib/instrumenters/istanbul.js +6 -12
- package/lib/instrumenters/noop.js +5 -5
- package/node_modules/arrify/package.json +1 -2
- package/node_modules/async/CHANGELOG.md +3 -0
- package/node_modules/async/package.json +11 -11
- package/node_modules/handlebars/dist/amd/handlebars/base.js +2 -2
- package/node_modules/handlebars/dist/amd/handlebars/compiler/javascript-compiler.js +4 -1
- package/node_modules/handlebars/dist/amd/handlebars/compiler/parser.js +3 -5
- package/node_modules/handlebars/dist/cjs/handlebars/base.js +2 -2
- package/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js +4 -1
- package/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js +3 -5
- package/node_modules/handlebars/dist/handlebars.amd.js +10 -9
- package/node_modules/handlebars/dist/handlebars.amd.min.js +4 -4
- package/node_modules/handlebars/dist/handlebars.js +7 -6
- package/node_modules/handlebars/dist/handlebars.min.js +4 -4
- package/node_modules/handlebars/dist/handlebars.runtime.amd.js +3 -3
- package/node_modules/handlebars/dist/handlebars.runtime.amd.min.js +2 -2
- package/node_modules/handlebars/dist/handlebars.runtime.js +2 -2
- package/node_modules/handlebars/dist/handlebars.runtime.min.js +2 -2
- package/node_modules/handlebars/lib/handlebars/base.js +1 -1
- package/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js +3 -0
- package/node_modules/handlebars/lib/handlebars/compiler/parser.js +9 -9
- package/node_modules/handlebars/lib/handlebars.d.ts +356 -0
- package/node_modules/handlebars/package.json +12 -11
- package/node_modules/handlebars/release-notes.md +38 -1
- package/node_modules/istanbul-reports/CHANGELOG.md +11 -0
- package/node_modules/istanbul-reports/package.json +12 -12
- package/node_modules/mem/index.js +5 -1
- package/node_modules/mem/package.json +14 -14
- package/node_modules/normalize-package-data/README.md +1 -1
- package/node_modules/normalize-package-data/lib/fixer.js +3 -2
- package/node_modules/normalize-package-data/package.json +13 -13
- package/node_modules/p-is-promise/index.d.ts +13 -0
- package/node_modules/p-is-promise/index.js +10 -6
- package/node_modules/p-is-promise/license +4 -16
- package/node_modules/p-is-promise/package.json +17 -18
- package/node_modules/p-is-promise/readme.md +1 -1
- package/node_modules/path-parse/.travis.yml +9 -0
- package/node_modules/{is-builtin-module/license → path-parse/LICENSE} +5 -5
- package/node_modules/path-parse/README.md +42 -0
- package/node_modules/path-parse/index.js +93 -0
- package/node_modules/path-parse/package.json +64 -0
- package/node_modules/path-parse/test.js +77 -0
- package/node_modules/resolve/.editorconfig +20 -0
- package/node_modules/resolve/.eslintignore +1 -0
- package/node_modules/resolve/.eslintrc +31 -0
- package/node_modules/resolve/.travis.yml +269 -0
- package/node_modules/resolve/CHANGELOG.md +629 -0
- package/node_modules/resolve/LICENSE +18 -0
- package/node_modules/resolve/appveyor.yml +47 -0
- package/node_modules/resolve/changelog.hbs +36 -0
- package/node_modules/resolve/example/async.js +5 -0
- package/node_modules/resolve/example/sync.js +3 -0
- package/node_modules/resolve/index.js +8 -0
- package/node_modules/resolve/lib/async.js +229 -0
- package/node_modules/resolve/lib/caller.js +8 -0
- package/node_modules/resolve/lib/core.js +53 -0
- package/node_modules/resolve/lib/core.json +73 -0
- package/node_modules/resolve/lib/node-modules-paths.js +42 -0
- package/node_modules/resolve/lib/normalize-options.js +10 -0
- package/node_modules/resolve/lib/sync.js +154 -0
- package/node_modules/resolve/package.json +77 -0
- package/node_modules/resolve/readme.markdown +179 -0
- package/node_modules/resolve/test/.eslintrc +5 -0
- package/node_modules/resolve/test/core.js +82 -0
- package/node_modules/resolve/test/dotdot/abc/index.js +2 -0
- package/node_modules/resolve/test/dotdot/index.js +1 -0
- package/node_modules/resolve/test/dotdot.js +29 -0
- package/node_modules/resolve/test/faulty_basedir.js +29 -0
- package/node_modules/resolve/test/filter.js +34 -0
- package/node_modules/resolve/test/filter_sync.js +26 -0
- package/node_modules/resolve/test/mock.js +143 -0
- package/node_modules/resolve/test/mock_sync.js +67 -0
- package/node_modules/resolve/test/module_dir/xmodules/aaa/index.js +1 -0
- package/node_modules/resolve/test/module_dir/ymodules/aaa/index.js +1 -0
- package/node_modules/resolve/test/module_dir/zmodules/bbb/main.js +1 -0
- package/node_modules/resolve/test/module_dir/zmodules/bbb/package.json +3 -0
- package/node_modules/resolve/test/module_dir.js +56 -0
- package/node_modules/resolve/test/node-modules-paths.js +121 -0
- package/node_modules/resolve/test/node_path/x/aaa/index.js +1 -0
- package/node_modules/resolve/test/node_path/x/ccc/index.js +1 -0
- package/node_modules/resolve/test/node_path/y/bbb/index.js +1 -0
- package/node_modules/resolve/test/node_path/y/ccc/index.js +1 -0
- package/node_modules/resolve/test/node_path.js +70 -0
- package/node_modules/resolve/test/nonstring.js +9 -0
- package/node_modules/resolve/test/pathfilter/deep_ref/main.js +0 -0
- package/node_modules/resolve/test/pathfilter.js +75 -0
- package/node_modules/resolve/test/precedence/aaa/index.js +1 -0
- package/node_modules/resolve/test/precedence/aaa/main.js +1 -0
- package/node_modules/resolve/test/precedence/aaa.js +1 -0
- package/node_modules/resolve/test/precedence/bbb/main.js +1 -0
- package/node_modules/resolve/test/precedence/bbb.js +1 -0
- package/node_modules/resolve/test/precedence.js +23 -0
- package/node_modules/resolve/test/resolver/baz/doom.js +0 -0
- package/node_modules/resolve/test/resolver/baz/package.json +3 -0
- package/node_modules/resolve/test/resolver/baz/quux.js +1 -0
- package/node_modules/resolve/test/resolver/browser_field/a.js +0 -0
- package/node_modules/resolve/test/resolver/browser_field/b.js +0 -0
- package/node_modules/resolve/test/resolver/browser_field/package.json +5 -0
- package/node_modules/resolve/test/resolver/cup.coffee +1 -0
- package/node_modules/resolve/test/resolver/dot_main/index.js +1 -0
- package/node_modules/resolve/test/resolver/dot_main/package.json +3 -0
- package/node_modules/resolve/test/resolver/dot_slash_main/index.js +1 -0
- package/node_modules/resolve/test/resolver/dot_slash_main/package.json +3 -0
- package/node_modules/resolve/test/resolver/foo.js +1 -0
- package/node_modules/resolve/test/resolver/incorrect_main/index.js +2 -0
- package/node_modules/resolve/test/resolver/incorrect_main/package.json +3 -0
- package/node_modules/resolve/test/resolver/invalid_main/package.json +7 -0
- package/node_modules/resolve/test/resolver/mug.coffee +0 -0
- package/node_modules/resolve/test/resolver/mug.js +0 -0
- package/node_modules/resolve/test/resolver/multirepo/lerna.json +6 -0
- package/node_modules/resolve/test/resolver/multirepo/package.json +20 -0
- package/node_modules/resolve/test/resolver/multirepo/packages/package-a/index.js +35 -0
- package/node_modules/resolve/test/resolver/multirepo/packages/package-a/package.json +14 -0
- package/node_modules/resolve/test/resolver/multirepo/packages/package-b/index.js +0 -0
- package/node_modules/resolve/test/resolver/multirepo/packages/package-b/package.json +14 -0
- package/node_modules/resolve/test/resolver/other_path/lib/other-lib.js +0 -0
- package/node_modules/resolve/test/resolver/other_path/root.js +0 -0
- package/node_modules/resolve/test/resolver/quux/foo/index.js +1 -0
- package/node_modules/resolve/test/resolver/same_names/foo/index.js +1 -0
- package/node_modules/resolve/test/resolver/same_names/foo.js +1 -0
- package/node_modules/resolve/test/resolver/symlinked/_/node_modules/foo.js +0 -0
- package/node_modules/resolve/test/resolver/symlinked/_/symlink_target/.gitkeep +0 -0
- package/node_modules/resolve/test/resolver/without_basedir/main.js +5 -0
- package/node_modules/resolve/test/resolver.js +429 -0
- package/node_modules/resolve/test/resolver_sync.js +340 -0
- package/node_modules/resolve/test/subdirs.js +13 -0
- package/node_modules/resolve/test/symlinks.js +56 -0
- package/package.json +3 -3
- package/node_modules/builtin-modules/builtin-modules.json +0 -35
- package/node_modules/builtin-modules/index.js +0 -10
- package/node_modules/builtin-modules/license +0 -21
- package/node_modules/builtin-modules/package.json +0 -75
- package/node_modules/builtin-modules/readme.md +0 -41
- package/node_modules/builtin-modules/static.js +0 -2
- package/node_modules/is-builtin-module/index.js +0 -10
- package/node_modules/is-builtin-module/package.json +0 -78
- package/node_modules/is-builtin-module/readme.md +0 -33
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
"resolve@1.10.0",
|
|
5
|
+
"/usr/src/npm/nyc"
|
|
6
|
+
]
|
|
7
|
+
],
|
|
8
|
+
"_from": "resolve@1.10.0",
|
|
9
|
+
"_id": "resolve@1.10.0",
|
|
10
|
+
"_inBundle": false,
|
|
11
|
+
"_integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
|
|
12
|
+
"_location": "/resolve",
|
|
13
|
+
"_phantomChildren": {},
|
|
14
|
+
"_requested": {
|
|
15
|
+
"type": "version",
|
|
16
|
+
"registry": true,
|
|
17
|
+
"raw": "resolve@1.10.0",
|
|
18
|
+
"name": "resolve",
|
|
19
|
+
"escapedName": "resolve",
|
|
20
|
+
"rawSpec": "1.10.0",
|
|
21
|
+
"saveSpec": null,
|
|
22
|
+
"fetchSpec": "1.10.0"
|
|
23
|
+
},
|
|
24
|
+
"_requiredBy": [
|
|
25
|
+
"/eslint-import-resolver-node",
|
|
26
|
+
"/eslint-plugin-import",
|
|
27
|
+
"/eslint-plugin-node",
|
|
28
|
+
"/normalize-package-data"
|
|
29
|
+
],
|
|
30
|
+
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz",
|
|
31
|
+
"_spec": "1.10.0",
|
|
32
|
+
"_where": "/usr/src/npm/nyc",
|
|
33
|
+
"author": {
|
|
34
|
+
"name": "James Halliday",
|
|
35
|
+
"email": "mail@substack.net",
|
|
36
|
+
"url": "http://substack.net"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/browserify/resolve/issues"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"path-parse": "^1.0.6"
|
|
43
|
+
},
|
|
44
|
+
"description": "resolve like require.resolve() on behalf of files asynchronously and synchronously",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@ljharb/eslint-config": "^13.1.1",
|
|
47
|
+
"eslint": "^5.12.0",
|
|
48
|
+
"object-keys": "^1.0.12",
|
|
49
|
+
"safe-publish-latest": "^1.1.2",
|
|
50
|
+
"tap": "0.4.13",
|
|
51
|
+
"tape": "^4.9.2"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/browserify/resolve#readme",
|
|
54
|
+
"keywords": [
|
|
55
|
+
"resolve",
|
|
56
|
+
"require",
|
|
57
|
+
"node",
|
|
58
|
+
"module"
|
|
59
|
+
],
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"main": "index.js",
|
|
62
|
+
"name": "resolve",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git://github.com/browserify/resolve.git"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"lint": "eslint .",
|
|
69
|
+
"posttest": "npm run test:multirepo",
|
|
70
|
+
"prepublish": "safe-publish-latest",
|
|
71
|
+
"pretest": "npm run lint",
|
|
72
|
+
"test": "npm run --silent tests-only",
|
|
73
|
+
"test:multirepo": "cd ./test/resolver/multirepo && npm install && npm test",
|
|
74
|
+
"tests-only": "tape test/*.js"
|
|
75
|
+
},
|
|
76
|
+
"version": "1.10.0"
|
|
77
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# resolve
|
|
2
|
+
|
|
3
|
+
implements the [node `require.resolve()`
|
|
4
|
+
algorithm](https://nodejs.org/api/modules.html#modules_all_together)
|
|
5
|
+
such that you can `require.resolve()` on behalf of a file asynchronously and
|
|
6
|
+
synchronously
|
|
7
|
+
|
|
8
|
+
[](http://travis-ci.org/browserify/node-resolve)
|
|
9
|
+
|
|
10
|
+
# example
|
|
11
|
+
|
|
12
|
+
asynchronously resolve:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
var resolve = require('resolve');
|
|
16
|
+
resolve('tap', { basedir: __dirname }, function (err, res) {
|
|
17
|
+
if (err) console.error(err);
|
|
18
|
+
else console.log(res);
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
$ node example/async.js
|
|
24
|
+
/home/substack/projects/node-resolve/node_modules/tap/lib/main.js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
synchronously resolve:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
var resolve = require('resolve');
|
|
31
|
+
var res = resolve.sync('tap', { basedir: __dirname });
|
|
32
|
+
console.log(res);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
$ node example/sync.js
|
|
37
|
+
/home/substack/projects/node-resolve/node_modules/tap/lib/main.js
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# methods
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
var resolve = require('resolve');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## resolve(id, opts={}, cb)
|
|
47
|
+
|
|
48
|
+
Asynchronously resolve the module path string `id` into `cb(err, res [, pkg])`, where `pkg` (if defined) is the data from `package.json`.
|
|
49
|
+
|
|
50
|
+
options are:
|
|
51
|
+
|
|
52
|
+
* opts.basedir - directory to begin resolving from
|
|
53
|
+
|
|
54
|
+
* opts.package - `package.json` data applicable to the module being loaded
|
|
55
|
+
|
|
56
|
+
* opts.extensions - array of file extensions to search in order
|
|
57
|
+
|
|
58
|
+
* opts.readFile - how to read files asynchronously
|
|
59
|
+
|
|
60
|
+
* opts.isFile - function to asynchronously test whether a file exists
|
|
61
|
+
|
|
62
|
+
* `opts.packageFilter(pkg, pkgfile)` - transform the parsed package.json contents before looking at the "main" field
|
|
63
|
+
* pkg - package data
|
|
64
|
+
* pkgfile - path to package.json
|
|
65
|
+
|
|
66
|
+
* `opts.pathFilter(pkg, path, relativePath)` - transform a path within a package
|
|
67
|
+
* pkg - package data
|
|
68
|
+
* path - the path being resolved
|
|
69
|
+
* relativePath - the path relative from the package.json location
|
|
70
|
+
* returns - a relative path that will be joined from the package.json location
|
|
71
|
+
|
|
72
|
+
* opts.paths - require.paths array to use if nothing is found on the normal `node_modules` recursive walk (probably don't use this)
|
|
73
|
+
|
|
74
|
+
For advanced users, `paths` can also be a `opts.paths(request, start, opts)` function
|
|
75
|
+
* request - the import specifier being resolved
|
|
76
|
+
* start - lookup path
|
|
77
|
+
* getNodeModulesDirs - a thunk (no-argument function) that returns the paths using standard `node_modules` resolution
|
|
78
|
+
* opts - the resolution options
|
|
79
|
+
|
|
80
|
+
* opts.moduleDirectory - directory (or directories) in which to recursively look for modules. default: `"node_modules"`
|
|
81
|
+
|
|
82
|
+
* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
|
|
83
|
+
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
|
|
84
|
+
**Note:** this property is currently `true` by default but it will be changed to
|
|
85
|
+
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
|
|
86
|
+
|
|
87
|
+
default `opts` values:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
{
|
|
91
|
+
paths: [],
|
|
92
|
+
basedir: __dirname,
|
|
93
|
+
extensions: ['.js'],
|
|
94
|
+
readFile: fs.readFile,
|
|
95
|
+
isFile: function isFile(file, cb) {
|
|
96
|
+
fs.stat(file, function (err, stat) {
|
|
97
|
+
if (!err) {
|
|
98
|
+
return cb(null, stat.isFile() || stat.isFIFO());
|
|
99
|
+
}
|
|
100
|
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
|
101
|
+
return cb(err);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
moduleDirectory: 'node_modules',
|
|
105
|
+
preserveSymlinks: true
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## resolve.sync(id, opts)
|
|
110
|
+
|
|
111
|
+
Synchronously resolve the module path string `id`, returning the result and
|
|
112
|
+
throwing an error when `id` can't be resolved.
|
|
113
|
+
|
|
114
|
+
options are:
|
|
115
|
+
|
|
116
|
+
* opts.basedir - directory to begin resolving from
|
|
117
|
+
|
|
118
|
+
* opts.extensions - array of file extensions to search in order
|
|
119
|
+
|
|
120
|
+
* opts.readFile - how to read files synchronously
|
|
121
|
+
|
|
122
|
+
* opts.isFile - function to synchronously test whether a file exists
|
|
123
|
+
|
|
124
|
+
* `opts.packageFilter(pkg, dir)` - transform the parsed package.json contents before looking at the "main" field
|
|
125
|
+
* pkg - package data
|
|
126
|
+
* dir - directory for package.json (Note: the second argument will change to "pkgfile" in v2)
|
|
127
|
+
|
|
128
|
+
* `opts.pathFilter(pkg, path, relativePath)` - transform a path within a package
|
|
129
|
+
* pkg - package data
|
|
130
|
+
* path - the path being resolved
|
|
131
|
+
* relativePath - the path relative from the package.json location
|
|
132
|
+
* returns - a relative path that will be joined from the package.json location
|
|
133
|
+
|
|
134
|
+
* opts.paths - require.paths array to use if nothing is found on the normal `node_modules` recursive walk (probably don't use this)
|
|
135
|
+
|
|
136
|
+
* opts.moduleDirectory - directory (or directories) in which to recursively look for modules. default: `"node_modules"`
|
|
137
|
+
|
|
138
|
+
* opts.preserveSymlinks - if true, doesn't resolve `basedir` to real path before resolving.
|
|
139
|
+
This is the way Node resolves dependencies when executed with the [--preserve-symlinks](https://nodejs.org/api/all.html#cli_preserve_symlinks) flag.
|
|
140
|
+
**Note:** this property is currently `true` by default but it will be changed to
|
|
141
|
+
`false` in the next major version because *Node's resolution algorithm does not preserve symlinks by default*.
|
|
142
|
+
|
|
143
|
+
default `opts` values:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
{
|
|
147
|
+
paths: [],
|
|
148
|
+
basedir: __dirname,
|
|
149
|
+
extensions: ['.js'],
|
|
150
|
+
readFileSync: fs.readFileSync,
|
|
151
|
+
isFile: function isFile(file) {
|
|
152
|
+
try {
|
|
153
|
+
var stat = fs.statSync(file);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
|
156
|
+
throw e;
|
|
157
|
+
}
|
|
158
|
+
return stat.isFile() || stat.isFIFO();
|
|
159
|
+
},
|
|
160
|
+
moduleDirectory: 'node_modules',
|
|
161
|
+
preserveSymlinks: true
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## resolve.isCore(pkg)
|
|
166
|
+
|
|
167
|
+
Return whether a package is in core.
|
|
168
|
+
|
|
169
|
+
# install
|
|
170
|
+
|
|
171
|
+
With [npm](https://npmjs.org) do:
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
npm install resolve
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
# license
|
|
178
|
+
|
|
179
|
+
MIT
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var test = require('tape');
|
|
2
|
+
var keys = require('object-keys');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('core modules', function (t) {
|
|
6
|
+
t.test('isCore()', function (st) {
|
|
7
|
+
st.ok(resolve.isCore('fs'));
|
|
8
|
+
st.ok(resolve.isCore('net'));
|
|
9
|
+
st.ok(resolve.isCore('http'));
|
|
10
|
+
|
|
11
|
+
st.ok(!resolve.isCore('seq'));
|
|
12
|
+
st.ok(!resolve.isCore('../'));
|
|
13
|
+
st.end();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
t.test('core list', function (st) {
|
|
17
|
+
var cores = keys(resolve.core);
|
|
18
|
+
st.plan(cores.length);
|
|
19
|
+
|
|
20
|
+
for (var i = 0; i < cores.length; ++i) {
|
|
21
|
+
var mod = cores[i];
|
|
22
|
+
if (resolve.core[mod]) {
|
|
23
|
+
st.doesNotThrow(
|
|
24
|
+
function () { require(mod); }, // eslint-disable-line no-loop-func
|
|
25
|
+
mod + ' supported; requiring does not throw'
|
|
26
|
+
);
|
|
27
|
+
} else {
|
|
28
|
+
st.throws(
|
|
29
|
+
function () { require(mod); }, // eslint-disable-line no-loop-func
|
|
30
|
+
mod + ' not supported; requiring throws'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
st.end();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
t.test('core via repl module', { skip: !resolve.core.repl }, function (st) {
|
|
39
|
+
var libs = require('repl')._builtinLibs; // eslint-disable-line no-underscore-dangle
|
|
40
|
+
if (!libs) {
|
|
41
|
+
st.skip('module.builtinModules does not exist');
|
|
42
|
+
return st.end();
|
|
43
|
+
}
|
|
44
|
+
for (var i = 0; i < libs.length; ++i) {
|
|
45
|
+
var mod = libs[i];
|
|
46
|
+
st.ok(resolve.core[mod], mod + ' is a core module');
|
|
47
|
+
st.doesNotThrow(
|
|
48
|
+
function () { require(mod); }, // eslint-disable-line no-loop-func
|
|
49
|
+
'requiring ' + mod + ' does not throw'
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
st.end();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
t.test('core via builtinModules list', { skip: !resolve.core.module }, function (st) {
|
|
56
|
+
var libs = require('module').builtinModules;
|
|
57
|
+
if (!libs) {
|
|
58
|
+
st.skip('module.builtinModules does not exist');
|
|
59
|
+
return st.end();
|
|
60
|
+
}
|
|
61
|
+
var blacklist = [
|
|
62
|
+
'_debug_agent',
|
|
63
|
+
'v8/tools/tickprocessor-driver',
|
|
64
|
+
'v8/tools/SourceMap',
|
|
65
|
+
'v8/tools/tickprocessor',
|
|
66
|
+
'v8/tools/profile'
|
|
67
|
+
];
|
|
68
|
+
for (var i = 0; i < libs.length; ++i) {
|
|
69
|
+
var mod = libs[i];
|
|
70
|
+
if (blacklist.indexOf(mod) === -1) {
|
|
71
|
+
st.ok(resolve.core[mod], mod + ' is a core module');
|
|
72
|
+
st.doesNotThrow(
|
|
73
|
+
function () { require(mod); }, // eslint-disable-line no-loop-func
|
|
74
|
+
'requiring ' + mod + ' does not throw'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
st.end();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
t.end();
|
|
82
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = 'whatever';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('dotdot', function (t) {
|
|
6
|
+
t.plan(4);
|
|
7
|
+
var dir = path.join(__dirname, '/dotdot/abc');
|
|
8
|
+
|
|
9
|
+
resolve('..', { basedir: dir }, function (err, res, pkg) {
|
|
10
|
+
t.ifError(err);
|
|
11
|
+
t.equal(res, path.join(__dirname, 'dotdot/index.js'));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
resolve('.', { basedir: dir }, function (err, res, pkg) {
|
|
15
|
+
t.ifError(err);
|
|
16
|
+
t.equal(res, path.join(dir, 'index.js'));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('dotdot sync', function (t) {
|
|
21
|
+
t.plan(2);
|
|
22
|
+
var dir = path.join(__dirname, '/dotdot/abc');
|
|
23
|
+
|
|
24
|
+
var a = resolve.sync('..', { basedir: dir });
|
|
25
|
+
t.equal(a, path.join(__dirname, 'dotdot/index.js'));
|
|
26
|
+
|
|
27
|
+
var b = resolve.sync('.', { basedir: dir });
|
|
28
|
+
t.equal(b, path.join(dir, 'index.js'));
|
|
29
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var test = require('tape');
|
|
2
|
+
var path = require('path');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('faulty basedir must produce error in windows', { skip: process.platform !== 'win32' }, function (t) {
|
|
6
|
+
t.plan(1);
|
|
7
|
+
|
|
8
|
+
var resolverDir = 'C:\\a\\b\\c\\d';
|
|
9
|
+
|
|
10
|
+
resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) {
|
|
11
|
+
t.equal(!!err, true);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('non-existent basedir should not throw when preserveSymlinks is false', function (t) {
|
|
16
|
+
t.plan(2);
|
|
17
|
+
|
|
18
|
+
var opts = {
|
|
19
|
+
basedir: path.join(path.sep, 'unreal', 'path', 'that', 'does', 'not', 'exist'),
|
|
20
|
+
preserveSymlinks: false
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var module = './dotdot/abc';
|
|
24
|
+
|
|
25
|
+
resolve(module, opts, function (err, res) {
|
|
26
|
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
|
27
|
+
t.equal(res, undefined);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('filter', function (t) {
|
|
6
|
+
t.plan(4);
|
|
7
|
+
var dir = path.join(__dirname, 'resolver');
|
|
8
|
+
var packageFilterArgs;
|
|
9
|
+
resolve('./baz', {
|
|
10
|
+
basedir: dir,
|
|
11
|
+
packageFilter: function (pkg, pkgfile) {
|
|
12
|
+
pkg.main = 'doom';
|
|
13
|
+
packageFilterArgs = [pkg, pkgfile];
|
|
14
|
+
return pkg;
|
|
15
|
+
}
|
|
16
|
+
}, function (err, res, pkg) {
|
|
17
|
+
if (err) t.fail(err);
|
|
18
|
+
|
|
19
|
+
t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
|
|
20
|
+
|
|
21
|
+
var packageData = packageFilterArgs[0];
|
|
22
|
+
t.equal(pkg, packageData, 'first packageFilter argument is "pkg"');
|
|
23
|
+
t.equal(packageData.main, 'doom', 'package "main" was altered');
|
|
24
|
+
|
|
25
|
+
var packageFile = packageFilterArgs[1];
|
|
26
|
+
t.equal(
|
|
27
|
+
packageFile,
|
|
28
|
+
path.join(dir, 'baz/package.json'),
|
|
29
|
+
'second packageFilter argument is "pkgfile"'
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
t.end();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('filter', function (t) {
|
|
6
|
+
var dir = path.join(__dirname, 'resolver');
|
|
7
|
+
var packageFilterArgs;
|
|
8
|
+
var res = resolve.sync('./baz', {
|
|
9
|
+
basedir: dir,
|
|
10
|
+
packageFilter: function (pkg, dir) {
|
|
11
|
+
pkg.main = 'doom';
|
|
12
|
+
packageFilterArgs = [pkg, dir];
|
|
13
|
+
return pkg;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
|
|
18
|
+
|
|
19
|
+
var packageData = packageFilterArgs[0];
|
|
20
|
+
t.equal(packageData.main, 'doom', 'package "main" was altered');
|
|
21
|
+
|
|
22
|
+
var packageFile = packageFilterArgs[1];
|
|
23
|
+
t.equal(packageFile, path.join(dir, 'baz'), 'second packageFilter argument is "dir"');
|
|
24
|
+
|
|
25
|
+
t.end();
|
|
26
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('mock', function (t) {
|
|
6
|
+
t.plan(8);
|
|
7
|
+
|
|
8
|
+
var files = {};
|
|
9
|
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
|
10
|
+
|
|
11
|
+
function opts(basedir) {
|
|
12
|
+
return {
|
|
13
|
+
basedir: path.resolve(basedir),
|
|
14
|
+
isFile: function (file, cb) {
|
|
15
|
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
|
16
|
+
},
|
|
17
|
+
readFile: function (file, cb) {
|
|
18
|
+
cb(null, files[path.resolve(file)]);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
|
|
24
|
+
if (err) return t.fail(err);
|
|
25
|
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
|
26
|
+
t.equal(pkg, undefined);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
|
|
30
|
+
if (err) return t.fail(err);
|
|
31
|
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
|
32
|
+
t.equal(pkg, undefined);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
resolve('baz', opts('/foo/bar'), function (err, res) {
|
|
36
|
+
t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
|
|
37
|
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
resolve('../baz', opts('/foo/bar'), function (err, res) {
|
|
41
|
+
t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
|
|
42
|
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('mock from package', function (t) {
|
|
47
|
+
t.plan(8);
|
|
48
|
+
|
|
49
|
+
var files = {};
|
|
50
|
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
|
51
|
+
|
|
52
|
+
function opts(basedir) {
|
|
53
|
+
return {
|
|
54
|
+
basedir: path.resolve(basedir),
|
|
55
|
+
isFile: function (file, cb) {
|
|
56
|
+
cb(null, Object.prototype.hasOwnProperty.call(files, file));
|
|
57
|
+
},
|
|
58
|
+
'package': { main: 'bar' },
|
|
59
|
+
readFile: function (file, cb) {
|
|
60
|
+
cb(null, files[file]);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
|
|
66
|
+
if (err) return t.fail(err);
|
|
67
|
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
|
68
|
+
t.equal(pkg && pkg.main, 'bar');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
|
|
72
|
+
if (err) return t.fail(err);
|
|
73
|
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
|
74
|
+
t.equal(pkg && pkg.main, 'bar');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
resolve('baz', opts('/foo/bar'), function (err, res) {
|
|
78
|
+
t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
|
|
79
|
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
resolve('../baz', opts('/foo/bar'), function (err, res) {
|
|
83
|
+
t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
|
|
84
|
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('mock package', function (t) {
|
|
89
|
+
t.plan(2);
|
|
90
|
+
|
|
91
|
+
var files = {};
|
|
92
|
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
|
93
|
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
|
94
|
+
main: './baz.js'
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function opts(basedir) {
|
|
98
|
+
return {
|
|
99
|
+
basedir: path.resolve(basedir),
|
|
100
|
+
isFile: function (file, cb) {
|
|
101
|
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
|
102
|
+
},
|
|
103
|
+
readFile: function (file, cb) {
|
|
104
|
+
cb(null, files[path.resolve(file)]);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
resolve('bar', opts('/foo'), function (err, res, pkg) {
|
|
110
|
+
if (err) return t.fail(err);
|
|
111
|
+
t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
|
|
112
|
+
t.equal(pkg && pkg.main, './baz.js');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('mock package from package', function (t) {
|
|
117
|
+
t.plan(2);
|
|
118
|
+
|
|
119
|
+
var files = {};
|
|
120
|
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
|
121
|
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
|
122
|
+
main: './baz.js'
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
function opts(basedir) {
|
|
126
|
+
return {
|
|
127
|
+
basedir: path.resolve(basedir),
|
|
128
|
+
isFile: function (file, cb) {
|
|
129
|
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
|
130
|
+
},
|
|
131
|
+
'package': { main: 'bar' },
|
|
132
|
+
readFile: function (file, cb) {
|
|
133
|
+
cb(null, files[path.resolve(file)]);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
resolve('bar', opts('/foo'), function (err, res, pkg) {
|
|
139
|
+
if (err) return t.fail(err);
|
|
140
|
+
t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
|
|
141
|
+
t.equal(pkg && pkg.main, './baz.js');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var resolve = require('../');
|
|
4
|
+
|
|
5
|
+
test('mock', function (t) {
|
|
6
|
+
t.plan(4);
|
|
7
|
+
|
|
8
|
+
var files = {};
|
|
9
|
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
|
10
|
+
|
|
11
|
+
function opts(basedir) {
|
|
12
|
+
return {
|
|
13
|
+
basedir: path.resolve(basedir),
|
|
14
|
+
isFile: function (file) {
|
|
15
|
+
return Object.prototype.hasOwnProperty.call(files, file);
|
|
16
|
+
},
|
|
17
|
+
readFileSync: function (file) {
|
|
18
|
+
return files[file];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
t.equal(
|
|
24
|
+
resolve.sync('./baz', opts('/foo/bar')),
|
|
25
|
+
path.resolve('/foo/bar/baz.js')
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
t.equal(
|
|
29
|
+
resolve.sync('./baz.js', opts('/foo/bar')),
|
|
30
|
+
path.resolve('/foo/bar/baz.js')
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
t.throws(function () {
|
|
34
|
+
resolve.sync('baz', opts('/foo/bar'));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
t.throws(function () {
|
|
38
|
+
resolve.sync('../baz', opts('/foo/bar'));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('mock package', function (t) {
|
|
43
|
+
t.plan(1);
|
|
44
|
+
|
|
45
|
+
var files = {};
|
|
46
|
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
|
47
|
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
|
48
|
+
main: './baz.js'
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function opts(basedir) {
|
|
52
|
+
return {
|
|
53
|
+
basedir: path.resolve(basedir),
|
|
54
|
+
isFile: function (file) {
|
|
55
|
+
return Object.prototype.hasOwnProperty.call(files, file);
|
|
56
|
+
},
|
|
57
|
+
readFileSync: function (file) {
|
|
58
|
+
return files[file];
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
t.equal(
|
|
64
|
+
resolve.sync('bar', opts('/foo')),
|
|
65
|
+
path.resolve('/foo/node_modules/bar/baz.js')
|
|
66
|
+
);
|
|
67
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = function (x) { return x * 100; };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = function (x) { return x + 100; };
|