Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into skipnodemodules
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Nov 17, 2018
2 parents 06d5013 + 3170ce1 commit eaace7a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
24 changes: 22 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ language: node_js
os:
- linux
node_js:
- "10.7"
- "11.2"
- "10.13"
- "9.11"
- "8.11"
- "8.12"
- "7.10"
- "6.14"
- "5.12"
Expand Down Expand Up @@ -34,6 +35,22 @@ matrix:
include:
- node_js: "lts/*"
env: PRETEST=true
- node_js: "11.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "11.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.12"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "10.5"
Expand Down Expand Up @@ -70,6 +87,8 @@ matrix:
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.9"
Expand Down Expand Up @@ -223,3 +242,4 @@ matrix:
allow_failures:
- os: osx
- env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"
7 changes: 5 additions & 2 deletions lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fs = require('fs');
var path = require('path');
var caller = require('./caller.js');
var nodeModulesPaths = require('./node-modules-paths.js');
var normalizeOptions = require('./normalize-options.js');

var defaultIsFile = function isFile(file, cb) {
fs.stat(file, function (err, stat) {
Expand All @@ -26,8 +27,8 @@ var defaultIsDir = function isDirectory(dir, cb) {

module.exports = function resolve(x, options, callback) {
var cb = callback;
var opts = options || {};
if (typeof opts === 'function') {
var opts = options;
if (typeof options === 'function') {
cb = opts;
opts = {};
}
Expand All @@ -38,6 +39,8 @@ module.exports = function resolve(x, options, callback) {
});
}

opts = normalizeOptions(x, opts);

var isFile = opts.isFile || defaultIsFile;
var isDirectory = opts.isDirectory || defaultIsDir;
var readFile = opts.readFile || fs.readFile;
Expand Down
10 changes: 10 additions & 0 deletions lib/normalize-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 || {};
};
4 changes: 3 additions & 1 deletion lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var fs = require('fs');
var path = require('path');
var caller = require('./caller.js');
var nodeModulesPaths = require('./node-modules-paths.js');
var normalizeOptions = require('./normalize-options.js');

var defaultIsFile = function isFile(file) {
try {
Expand All @@ -28,7 +29,8 @@ module.exports = function (x, options) {
if (typeof x !== 'string') {
throw new TypeError('Path must be a string.');
}
var opts = options || {};
var opts = normalizeOptions(x, options);

var isFile = opts.isFile || defaultIsFile;
var isDirectory = opts.isDirectory || defaultIsDir;
var readFileSync = opts.readFileSync || fs.readFileSync;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"devDependencies": {
"@ljharb/eslint-config": "^13.0.0",
"eslint": "^5.2.0",
"eslint": "^5.9.0",
"object-keys": "^1.0.12",
"safe-publish-latest": "^1.1.1",
"safe-publish-latest": "^1.1.2",
"tap": "0.4.13",
"tape": "^4.9.1"
},
Expand All @@ -35,6 +35,6 @@
"url": "http://substack.net"
},
"dependencies": {
"path-parse": "^1.0.5"
"path-parse": "^1.0.6"
}
}

0 comments on commit eaace7a

Please sign in to comment.