+27
-2
@@ -5,3 +5,4 @@ language: node_js | ||
| node_js: | ||
| - "11.6" | ||
| - "12.2" | ||
| - "11.15" | ||
| - "10.15" | ||
@@ -11,3 +12,3 @@ - "9.11" | ||
| - "7.10" | ||
| - "6.16" | ||
| - "6.17" | ||
| - "5.12" | ||
@@ -42,2 +43,24 @@ - "4.9" | ||
| env: POSTTEST=true | ||
| - node_js: "12.1" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "12.0" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.14" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.13" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.12" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.11" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.10" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.9" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.8" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.7" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.6" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "11.5" | ||
@@ -157,2 +180,4 @@ env: TEST=true ALLOW_FAILURE=true | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "6.16" | ||
| env: TEST=true ALLOW_FAILURE=true | ||
| - node_js: "6.15" | ||
@@ -159,0 +184,0 @@ env: TEST=true ALLOW_FAILURE=true |
+5
-1
@@ -5,4 +5,8 @@ ### Changelog | ||
| #### [Unreleased](https://github.com/browserify/resolve/compare/v1.10.0...HEAD) | ||
| #### [Unreleased](https://github.com/browserify/resolve/compare/v1.11.0...HEAD) | ||
| #### [v1.11.0](https://github.com/browserify/resolve/compare/v1.10.1...v1.11.0) - 15 May 2019 | ||
| - [New] Add `isDirectory`; use to speed up `node_modules` lookups (#192, #191, #190) | ||
| - [Tests] up to `node` `v12.2`, `v11.15`, `v6.17` | ||
| #### [v1.10.1](https://github.com/browserify/resolve/compare/v1.10.0...v1.10.1) - 23 April 2019 | ||
@@ -9,0 +13,0 @@ - [Fix] `core`: 6 `v8/` core modules and 3 `node-inspect/` core modules no longer exist in node 12 ([`b54d33a`][]) |
+19
-2
@@ -18,2 +18,12 @@ var core = require('./core'); | ||
| 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); | ||
| }); | ||
| }; | ||
| module.exports = function resolve(x, options, callback) { | ||
@@ -36,2 +46,3 @@ var cb = callback; | ||
| var isFile = opts.isFile || defaultIsFile; | ||
| var isDirectory = opts.isDirectory || defaultIsDir; | ||
| var readFile = opts.readFile || fs.readFile; | ||
@@ -213,5 +224,11 @@ | ||
| var file = path.join(dir, x); | ||
| loadAsFile(file, opts.package, onfile); | ||
| isDirectory(dir, isdir); | ||
| function isdir(err, isdir) { | ||
| if (err) return cb(err); | ||
| if (!isdir) return processDirs(cb, dirs.slice(1)); | ||
| var file = path.join(dir, x); | ||
| loadAsFile(file, opts.package, onfile); | ||
| } | ||
| function onfile(err, m, pkg) { | ||
@@ -218,0 +235,0 @@ if (err) return cb(err); |
+17
-4
@@ -18,2 +18,12 @@ var core = require('./core'); | ||
| 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(); | ||
| }; | ||
| module.exports = function (x, options) { | ||
@@ -27,2 +37,3 @@ if (typeof x !== 'string') { | ||
| var readFileSync = opts.readFileSync || fs.readFileSync; | ||
| var isDirectory = opts.isDirectory || defaultIsDir; | ||
@@ -150,8 +161,10 @@ var extensions = opts.extensions || ['.js']; | ||
| var dir = dirs[i]; | ||
| var m = loadAsFileSync(path.join(dir, '/', x)); | ||
| if (m) return m; | ||
| var n = loadAsDirectorySync(path.join(dir, '/', x)); | ||
| if (n) return n; | ||
| if (isDirectory(dir)) { | ||
| var m = loadAsFileSync(path.join(dir, '/', x)); | ||
| if (m) return m; | ||
| var n = loadAsDirectorySync(path.join(dir, '/', x)); | ||
| if (n) return n; | ||
| } | ||
| } | ||
| } | ||
| }; |
+1
-1
| { | ||
| "name": "resolve", | ||
| "description": "resolve like require.resolve() on behalf of files asynchronously and synchronously", | ||
| "version": "1.10.1", | ||
| "version": "1.11.0", | ||
| "repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
+17
-4
@@ -11,2 +11,5 @@ var path = require('path'); | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo/bar')] = true; | ||
| function opts(basedir) { | ||
@@ -16,6 +19,9 @@ return { | ||
| isFile: function (file) { | ||
| return Object.prototype.hasOwnProperty.call(files, file); | ||
| return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); | ||
| }, | ||
| isDirectory: function (dir) { | ||
| return !!dirs[path.resolve(dir)]; | ||
| }, | ||
| readFileSync: function (file) { | ||
| return files[file]; | ||
| return files[path.resolve(file)]; | ||
| } | ||
@@ -53,2 +59,6 @@ }; | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo')] = true; | ||
| dirs[path.resolve('/foo/node_modules')] = true; | ||
| function opts(basedir) { | ||
@@ -58,6 +68,9 @@ return { | ||
| isFile: function (file) { | ||
| return Object.prototype.hasOwnProperty.call(files, file); | ||
| return Object.prototype.hasOwnProperty.call(files, path.resolve(file)); | ||
| }, | ||
| isDirectory: function (dir) { | ||
| return !!dirs[path.resolve(dir)]; | ||
| }, | ||
| readFileSync: function (file) { | ||
| return files[file]; | ||
| return files[path.resolve(file)]; | ||
| } | ||
@@ -64,0 +77,0 @@ }; |
+26
-0
@@ -11,2 +11,5 @@ var path = require('path'); | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo/bar')] = true; | ||
| function opts(basedir) { | ||
@@ -18,2 +21,5 @@ return { | ||
| }, | ||
| isDirectory: function (dir, cb) { | ||
| cb(null, !!dirs[path.resolve(dir)]); | ||
| }, | ||
| readFile: function (file, cb) { | ||
@@ -54,2 +60,5 @@ cb(null, files[path.resolve(file)]); | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo/bar')] = true; | ||
| function opts(basedir) { | ||
@@ -61,2 +70,5 @@ return { | ||
| }, | ||
| isDirectory: function (dir, cb) { | ||
| cb(null, !!dirs[path.resolve(dir)]); | ||
| }, | ||
| 'package': { main: 'bar' }, | ||
@@ -101,2 +113,6 @@ readFile: function (file, cb) { | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo')] = true; | ||
| dirs[path.resolve('/foo/node_modules')] = true; | ||
| function opts(basedir) { | ||
@@ -108,2 +124,5 @@ return { | ||
| }, | ||
| isDirectory: function (dir, cb) { | ||
| cb(null, !!dirs[path.resolve(dir)]); | ||
| }, | ||
| readFile: function (file, cb) { | ||
@@ -131,2 +150,6 @@ cb(null, files[path.resolve(file)]); | ||
| var dirs = {}; | ||
| dirs[path.resolve('/foo')] = true; | ||
| dirs[path.resolve('/foo/node_modules')] = true; | ||
| function opts(basedir) { | ||
@@ -138,2 +161,5 @@ return { | ||
| }, | ||
| isDirectory: function (dir, cb) { | ||
| cb(null, !!dirs[path.resolve(dir)]); | ||
| }, | ||
| 'package': { main: 'bar' }, | ||
@@ -140,0 +166,0 @@ readFile: function (file, cb) { |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
140059
2.87%1980
3.13%202
12.22%