is-core-module
Advanced tools
Comparing version 2.8.1 to 2.9.0
@@ -8,2 +8,11 @@ # Changelog | ||
## [v2.9.0](https://github.com/inspect-js/is-core-module/compare/v2.8.1...v2.9.0) - 2022-04-19 | ||
### Commits | ||
- [New] add `node:test`, in node 18+ [`f853eca`](https://github.com/inspect-js/is-core-module/commit/f853eca801d0a7d4e1dbb670f1b6d9837d9533c5) | ||
- [Tests] use `mock-property` [`03b3644`](https://github.com/inspect-js/is-core-module/commit/03b3644dff4417f4ba5a7d0aa0138f5f6b3e5c46) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`7c0e2d0`](https://github.com/inspect-js/is-core-module/commit/7c0e2d06ed2a89acf53abe2ab34d703ed5b03455) | ||
- [meta] simplify "exports" [`d6ed201`](https://github.com/inspect-js/is-core-module/commit/d6ed201eba7fbba0e59814a9050fc49a6e9878c8) | ||
## [v2.8.1](https://github.com/inspect-js/is-core-module/compare/v2.8.0...v2.8.1) - 2022-01-05 | ||
@@ -10,0 +19,0 @@ |
@@ -115,2 +115,3 @@ { | ||
"node:sys": [">= 14.18 && < 15", ">= 16"], | ||
"node:test": ">= 18", | ||
"timers": true, | ||
@@ -117,0 +118,0 @@ "node:timers": [">= 14.18 && < 15", ">= 16"], |
{ | ||
"name": "is-core-module", | ||
"version": "2.8.1", | ||
"version": "2.9.0", | ||
"description": "Is this specifier a node.js core module?", | ||
@@ -8,8 +8,3 @@ "main": "index.js", | ||
"exports": { | ||
".": [ | ||
{ | ||
"default": "./index.js" | ||
}, | ||
"./index.js" | ||
], | ||
".": "./index.js", | ||
"./package.json": "./package.json" | ||
@@ -53,10 +48,11 @@ }, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^20.1.0", | ||
"aud": "^1.1.5", | ||
"auto-changelog": "^2.3.0", | ||
"eslint": "^8.6.0", | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"aud": "^2.0.0", | ||
"auto-changelog": "^2.4.0", | ||
"eslint": "=8.8.0", | ||
"mock-property": "^1.0.0", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^2.0.0", | ||
"semver": "^6.3.0", | ||
"tape": "^5.4.0" | ||
"tape": "^5.5.3" | ||
}, | ||
@@ -63,0 +59,0 @@ "auto-changelog": { |
@@ -6,2 +6,4 @@ 'use strict'; | ||
var semver = require('semver'); | ||
var mockProperty = require('mock-property'); | ||
var isCore = require('../'); | ||
@@ -55,12 +57,14 @@ var data = require('../core.json'); | ||
); | ||
if (supportsNodePrefix) { | ||
st.doesNotThrow( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' does not throw' | ||
); | ||
} else { | ||
st['throws']( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' throws' | ||
); | ||
if (mod.slice(0, 5) !== 'node:') { | ||
if (supportsNodePrefix) { | ||
st.doesNotThrow( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' does not throw' | ||
); | ||
} else { | ||
st['throws']( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' throws' | ||
); | ||
} | ||
} | ||
@@ -84,2 +88,6 @@ } | ||
]; | ||
// see https://github.com/nodejs/node/issues/42785 | ||
if (semver.satisfies(process.version, '>= 18')) { | ||
libs = libs.concat('node:test'); | ||
} | ||
for (var i = 0; i < libs.length; ++i) { | ||
@@ -93,12 +101,14 @@ var mod = libs[i]; | ||
); | ||
if (supportsNodePrefix) { | ||
st.doesNotThrow( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' does not throw' | ||
); | ||
} else { | ||
st['throws']( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' throws' | ||
); | ||
if (mod.slice(0, 5) !== 'node:') { | ||
if (supportsNodePrefix) { | ||
st.doesNotThrow( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' does not throw' | ||
); | ||
} else { | ||
st['throws']( | ||
function () { require('node:' + mod); }, // eslint-disable-line no-loop-func | ||
'requiring node:' + mod + ' throws' | ||
); | ||
} | ||
} | ||
@@ -112,14 +122,7 @@ } | ||
t.test('Object.prototype pollution', function (st) { | ||
/* eslint no-extend-native: 1 */ | ||
var nonKey = 'not a core module'; | ||
st.teardown(function () { | ||
delete Object.prototype.fs; | ||
delete Object.prototype.path; | ||
delete Object.prototype.http; | ||
delete Object.prototype[nonKey]; | ||
}); | ||
Object.prototype.fs = false; | ||
Object.prototype.path = '>= 999999999'; | ||
Object.prototype.http = data.http; | ||
Object.prototype[nonKey] = true; | ||
st.teardown(mockProperty(Object.prototype, 'fs', { value: false })); | ||
st.teardown(mockProperty(Object.prototype, 'path', { value: '>= 999999999' })); | ||
st.teardown(mockProperty(Object.prototype, 'http', { value: data.http })); | ||
st.teardown(mockProperty(Object.prototype, nonKey, { value: true })); | ||
@@ -126,0 +129,0 @@ st.equal(isCore('fs'), true, 'fs is a core module even if Object.prototype lies'); |
Sorry, the diff of this file is not supported yet
26849
329
9