Skip to content

Commit

Permalink
Merge branch 'master' into 147-shadowed-core-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
searls authored Mar 23, 2018
2 parents d00883c + 1de53b2 commit 60a5568
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 12 deletions.
22 changes: 19 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ language: node_js
os:
- linux
node_js:
- "9.3"
- "8.9"
- "9.8"
- "8.10"
- "7.10"
- "6.12"
- "6.13"
- "5.12"
- "4.8"
- "iojs-v3.3"
Expand All @@ -32,12 +32,24 @@ matrix:
include:
- node_js: "lts/*"
env: PRETEST=true
- node_js: "9.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "9.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.7"
Expand Down Expand Up @@ -76,6 +88,8 @@ matrix:
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.12"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.10"
Expand Down Expand Up @@ -176,6 +190,8 @@ matrix:
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.4"
env: TEST=true ALLOW_FAILURE=true
allow_failures:
Expand Down
25 changes: 22 additions & 3 deletions lib/core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];

function versionIncluded(specifier) {
if (specifier === true) { return true; }
function specifierIncluded(specifier) {
var parts = specifier.split(' ');
var op = parts[0];
var versionParts = parts[1].split('.');
Expand All @@ -20,7 +19,27 @@ function versionIncluded(specifier) {
return false;
}
}
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');
Expand Down
27 changes: 26 additions & 1 deletion lib/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@
"events": true,
"freelist": "< 6",
"fs": true,
"_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,
"_http_server": ">= 0.11",
"inspector": ">= 8.0.0",
"_linklist": "< 8",
"module": true,
"net": true,
"node-inspect/lib/_inspect": ">= 7.6.0",
"node-inspect/lib/internal/inspect_client": ">= 7.6.0",
"node-inspect/lib/internal/inspect_repl": ">= 7.6.0",
"os": true,
"path": true,
"perf_hooks": ">= 8.5",
Expand All @@ -30,14 +39,30 @@
"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,
"string_decoder": true,
"sys": true,
"timers": true,
"_tls_common": ">= 0.11.13",
"_tls_legacy": ">= 0.11.3",
"_tls_wrap": ">= 0.11.3",
"tls": true,
"tty": true,
"url": true,
"util": true,
"v8/tools/codemap": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8/tools/consarray": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8/tools/csvparser": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8/tools/logreader": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8/tools/profile_view": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0"],
"v8": ">= 1",
"vm": true,
"zlib": true
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "resolve",
"description": "resolve like require.resolve() on behalf of files asynchronously and synchronously",
"version": "1.5.0",
"version": "1.6.0",
"repository": {
"type": "git",
"url": "git://github.com/browserify/node-resolve.git"
Expand All @@ -22,11 +22,11 @@
},
"devDependencies": {
"@ljharb/eslint-config": "^12.2.1",
"eslint": "^4.14.0",
"eslint": "^4.19.0",
"object-keys": "^1.0.11",
"safe-publish-latest": "^1.1.1",
"tap": "0.4.13",
"tape": "^4.8.0"
"tape": "^4.9.0"
},
"license": "MIT",
"author": {
Expand Down
50 changes: 48 additions & 2 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,61 @@ test('core modules', function (t) {
if (resolve.core[mod]) {
st.doesNotThrow(
function () { require(mod); }, // eslint-disable-line no-loop-func
'requiring ' + mod + ' does not throw'
mod + ' supported; requiring does not throw'
);
} else {
st.skip(mod + ' not supported');
st.throws(
function () { require(mod); }, // eslint-disable-line no-loop-func
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();
});

0 comments on commit 60a5568

Please sign in to comment.