Comparing version 1.20.0 to 1.21.0
@@ -18,5 +18,4 @@ var current = (process.versions && process.versions.node && process.versions.node.split('.')) || []; | ||
return cur >= ver; | ||
} else { | ||
return false; | ||
} | ||
return false; | ||
} | ||
@@ -23,0 +22,0 @@ return op === '>='; |
{ | ||
"assert": true, | ||
"node:assert": [">= 14.18 && < 15", ">= 16"], | ||
"assert/strict": ">= 15", | ||
"node:assert/strict": ">= 16", | ||
"async_hooks": ">= 8", | ||
"node:async_hooks": [">= 14.18 && < 15", ">= 16"], | ||
"buffer_ieee754": "< 0.9.7", | ||
"buffer": true, | ||
"node:buffer": [">= 14.18 && < 15", ">= 16"], | ||
"child_process": true, | ||
"node:child_process": [">= 14.18 && < 15", ">= 16"], | ||
"cluster": true, | ||
"node:cluster": [">= 14.18 && < 15", ">= 16"], | ||
"console": true, | ||
"node:console": [">= 14.18 && < 15", ">= 16"], | ||
"constants": true, | ||
"node:constants": [">= 14.18 && < 15", ">= 16"], | ||
"crypto": true, | ||
"node:crypto": [">= 14.18 && < 15", ">= 16"], | ||
"_debug_agent": ">= 1 && < 8", | ||
"_debugger": "< 8", | ||
"dgram": true, | ||
"diagnostics_channel": ">= 15.1", | ||
"node:dgram": [">= 14.18 && < 15", ">= 16"], | ||
"diagnostics_channel": [">= 14.17 && < 15", ">= 15.1"], | ||
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"], | ||
"dns": true, | ||
"node:dns": [">= 14.18 && < 15", ">= 16"], | ||
"dns/promises": ">= 15", | ||
"node:dns/promises": ">= 16", | ||
"domain": ">= 0.7.12", | ||
"node:domain": [">= 14.18 && < 15", ">= 16"], | ||
"events": true, | ||
"node:events": [">= 14.18 && < 15", ">= 16"], | ||
"freelist": "< 6", | ||
"fs": true, | ||
"node:fs": [">= 14.18 && < 15", ">= 16"], | ||
"fs/promises": [">= 10 && < 10.1", ">= 14"], | ||
"node:fs/promises": [">= 14.18 && < 15", ">= 16"], | ||
"_http_agent": ">= 0.11.1", | ||
"node:_http_agent": [">= 14.18 && < 15", ">= 16"], | ||
"_http_client": ">= 0.11.1", | ||
"node:_http_client": [">= 14.18 && < 15", ">= 16"], | ||
"_http_common": ">= 0.11.1", | ||
"node:_http_common": [">= 14.18 && < 15", ">= 16"], | ||
"_http_incoming": ">= 0.11.1", | ||
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"], | ||
"_http_outgoing": ">= 0.11.1", | ||
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"], | ||
"_http_server": ">= 0.11.1", | ||
"node:_http_server": [">= 14.18 && < 15", ">= 16"], | ||
"http": true, | ||
"node:http": [">= 14.18 && < 15", ">= 16"], | ||
"http2": ">= 8.8", | ||
"node:http2": [">= 14.18 && < 15", ">= 16"], | ||
"https": true, | ||
"inspector": ">= 8.0.0", | ||
"node:https": [">= 14.18 && < 15", ">= 16"], | ||
"inspector": ">= 8", | ||
"node:inspector": [">= 14.18 && < 15", ">= 16"], | ||
"_linklist": "< 8", | ||
"module": true, | ||
"node:module": [">= 14.18 && < 15", ">= 16"], | ||
"net": true, | ||
"node-inspect/lib/_inspect": ">= 7.6.0 && < 12", | ||
"node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12", | ||
"node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12", | ||
"node:net": [">= 14.18 && < 15", ">= 16"], | ||
"node-inspect/lib/_inspect": ">= 7.6 && < 12", | ||
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12", | ||
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12", | ||
"os": true, | ||
"node:os": [">= 14.18 && < 15", ">= 16"], | ||
"path": true, | ||
"node:path": [">= 14.18 && < 15", ">= 16"], | ||
"path/posix": ">= 15.3", | ||
"node:path/posix": ">= 16", | ||
"path/win32": ">= 15.3", | ||
"node:path/win32": ">= 16", | ||
"perf_hooks": ">= 8.5", | ||
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"], | ||
"process": ">= 1", | ||
"node:process": [">= 14.18 && < 15", ">= 16"], | ||
"punycode": true, | ||
"node:punycode": [">= 14.18 && < 15", ">= 16"], | ||
"querystring": true, | ||
"node:querystring": [">= 14.18 && < 15", ">= 16"], | ||
"readline": true, | ||
"node:readline": [">= 14.18 && < 15", ">= 16"], | ||
"readline/promises": ">= 17", | ||
"node:readline/promises": ">= 17", | ||
"repl": true, | ||
"node:repl": [">= 14.18 && < 15", ">= 16"], | ||
"smalloc": ">= 0.11.5 && < 3", | ||
"_stream_duplex": ">= 0.9.4", | ||
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"], | ||
"_stream_transform": ">= 0.9.4", | ||
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"], | ||
"_stream_wrap": ">= 1.4.1", | ||
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"], | ||
"_stream_passthrough": ">= 0.9.4", | ||
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"], | ||
"_stream_readable": ">= 0.9.4", | ||
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"], | ||
"_stream_writable": ">= 0.9.4", | ||
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"], | ||
"stream": true, | ||
"node:stream": [">= 14.18 && < 15", ">= 16"], | ||
"stream/consumers": ">= 16.7", | ||
"node:stream/consumers": ">= 16.7", | ||
"stream/promises": ">= 15", | ||
"node:stream/promises": ">= 16", | ||
"stream/web": ">= 16.5", | ||
"node:stream/web": ">= 16.5", | ||
"string_decoder": true, | ||
"node:string_decoder": [">= 14.18 && < 15", ">= 16"], | ||
"sys": [">= 0.6 && < 0.7", ">= 0.8"], | ||
"node:sys": [">= 14.18 && < 15", ">= 16"], | ||
"timers": true, | ||
"node:timers": [">= 14.18 && < 15", ">= 16"], | ||
"timers/promises": ">= 15", | ||
"node:timers/promises": ">= 16", | ||
"_tls_common": ">= 0.11.13", | ||
"node:_tls_common": [">= 14.18 && < 15", ">= 16"], | ||
"_tls_legacy": ">= 0.11.3 && < 10", | ||
"_tls_wrap": ">= 0.11.3", | ||
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"], | ||
"tls": true, | ||
"node:tls": [">= 14.18 && < 15", ">= 16"], | ||
"trace_events": ">= 10", | ||
"node:trace_events": [">= 14.18 && < 15", ">= 16"], | ||
"tty": true, | ||
"node:tty": [">= 14.18 && < 15", ">= 16"], | ||
"url": true, | ||
"node:url": [">= 14.18 && < 15", ">= 16"], | ||
"util": true, | ||
"node:util": [">= 14.18 && < 15", ">= 16"], | ||
"util/types": ">= 15.3", | ||
"node:util/types": ">= 16", | ||
"v8/tools/arguments": ">= 10 && < 12", | ||
"v8/tools/codemap": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/consarray": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/csvparser": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/logreader": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/profile_view": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"], | ||
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"], | ||
"v8": ">= 1", | ||
"node:v8": [">= 14.18 && < 15", ">= 16"], | ||
"vm": true, | ||
"node:vm": [">= 14.18 && < 15", ">= 16"], | ||
"wasi": ">= 13.4 && < 13.5", | ||
"worker_threads": ">= 11.7", | ||
"zlib": true | ||
"node:worker_threads": [">= 14.18 && < 15", ">= 16"], | ||
"zlib": true, | ||
"node:zlib": [">= 14.18 && < 15", ">= 16"] | ||
} |
var path = require('path'); | ||
var parse = path.parse || require('path-parse'); | ||
var parse = path.parse || require('path-parse'); // eslint-disable-line global-require | ||
@@ -4,0 +4,0 @@ var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) { |
@@ -12,3 +12,3 @@ var isCore = require('is-core-module'); | ||
try { | ||
var stat = fs.statSync(file); | ||
var stat = fs.statSync(file, { throwIfNoEntry: false }); | ||
} catch (e) { | ||
@@ -18,3 +18,3 @@ if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; | ||
} | ||
return stat.isFile() || stat.isFIFO(); | ||
return !!stat && (stat.isFile() || stat.isFIFO()); | ||
}; | ||
@@ -24,3 +24,3 @@ | ||
try { | ||
var stat = fs.statSync(dir); | ||
var stat = fs.statSync(dir, { throwIfNoEntry: false }); | ||
} catch (e) { | ||
@@ -30,3 +30,3 @@ if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false; | ||
} | ||
return stat.isDirectory(); | ||
return !!stat && stat.isDirectory(); | ||
}; | ||
@@ -33,0 +33,0 @@ |
{ | ||
"name": "resolve", | ||
"description": "resolve like require.resolve() on behalf of files asynchronously and synchronously", | ||
"version": "1.20.0", | ||
"version": "1.21.0", | ||
"repository": { | ||
@@ -9,2 +9,5 @@ "type": "git", | ||
}, | ||
"bin": { | ||
"resolve": "./bin/resolve" | ||
}, | ||
"main": "index.js", | ||
@@ -18,5 +21,6 @@ "keywords": [ | ||
"scripts": { | ||
"prepublish": "safe-publish-latest && cp node_modules/is-core-module/core.json ./lib/ ||:", | ||
"prelint": "eclint check '**/*'", | ||
"lint": "eslint --ext=js,mjs .", | ||
"prepublishOnly": "safe-publish-latest && cp node_modules/is-core-module/core.json ./lib/ ||:", | ||
"prepublish": "not-in-publish || npm run prepublishOnly", | ||
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", | ||
"lint": "eslint --ext=js,mjs --no-eslintrc -c .eslintrc . 'bin/**'", | ||
"pretests-only": "cd ./test/resolver/nested_symlinks && node mylib/sync && node mylib/async", | ||
@@ -30,11 +34,12 @@ "tests-only": "tape test/*.js", | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^17.5.1", | ||
"array.prototype.map": "^1.0.3", | ||
"aud": "^1.1.4", | ||
"@ljharb/eslint-config": "^20.1.0", | ||
"array.prototype.map": "^1.0.4", | ||
"aud": "^1.1.5", | ||
"eclint": "^2.8.1", | ||
"eslint": "^7.19.0", | ||
"eslint": "^8.6.0", | ||
"in-publish": "^2.0.1", | ||
"object-keys": "^1.1.1", | ||
"safe-publish-latest": "^1.1.4", | ||
"safe-publish-latest": "^2.0.0", | ||
"tap": "0.4.13", | ||
"tape": "^5.1.1" | ||
"tape": "^5.4.0" | ||
}, | ||
@@ -51,5 +56,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"is-core-module": "^2.2.0", | ||
"path-parse": "^1.0.6" | ||
"is-core-module": "^2.8.0", | ||
"path-parse": "^1.0.7", | ||
"supports-preserve-symlinks-flag": "^1.0.0" | ||
} | ||
} |
@@ -125,5 +125,4 @@ var path = require('path'); | ||
return path.join(dir, 'symlinked', base); | ||
} else { | ||
return path.join(resolved, 'symlinked'); | ||
} | ||
return path.join(resolved, 'symlinked'); | ||
} | ||
@@ -187,5 +186,4 @@ }; | ||
return { main: './something-else.js' }; | ||
} else { | ||
return JSON.parse(files[path.resolve(file)]); | ||
} | ||
return JSON.parse(files[path.resolve(file)]); | ||
}; | ||
@@ -192,0 +190,0 @@ |
@@ -66,3 +66,3 @@ var fs = require('fs'); | ||
}, function (err, res) { | ||
var root = require('tap/package.json').main; | ||
var root = require('tap/package.json').main; // eslint-disable-line global-require | ||
t.error(err); | ||
@@ -69,0 +69,0 @@ t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap', root), 'tap resolves'); |
var path = require('path'); | ||
var fs = require('fs'); | ||
var test = require('tape'); | ||
var resolve = require('../'); | ||
var sync = require('../sync'); | ||
test('`./sync` entry point', function (t) { | ||
t.equal(resolve.sync, sync, '`./sync` entry point is the same as `.sync` on `main`'); | ||
t.end(); | ||
}); | ||
test('foo', function (t) { | ||
@@ -203,3 +211,2 @@ var dir = path.join(__dirname, 'resolver'); | ||
var stubStatSync = function stubStatSync(fn) { | ||
var fs = require('fs'); | ||
var statSync = fs.statSync; | ||
@@ -325,3 +332,3 @@ try { | ||
t.ok(err, 'errors on non-string main'); | ||
t.equal(err.message, 'package “invalid main” `main` must be a string'); | ||
t.equal(err.message, 'package “invalid_main” `main` must be a string'); | ||
t.equal(err.code, 'INVALID_PACKAGE_MAIN'); | ||
@@ -340,3 +347,3 @@ } | ||
t.ok(err, 'errors on non-string main'); | ||
t.equal(err.message, 'package “invalid main” `main` must be a string'); | ||
t.equal(err.message, 'package “invalid_main” `main` must be a string'); | ||
t.equal(err.code, 'INVALID_PACKAGE_MAIN'); | ||
@@ -362,1 +369,79 @@ } | ||
}); | ||
test('absolute paths', function (t) { | ||
var extensionless = __filename.slice(0, -path.extname(__filename).length); | ||
t.equal( | ||
resolve.sync(__filename), | ||
__filename, | ||
'absolute path to this file resolves' | ||
); | ||
t.equal( | ||
resolve.sync(extensionless), | ||
__filename, | ||
'extensionless absolute path to this file resolves' | ||
); | ||
t.equal( | ||
resolve.sync(__filename, { basedir: process.cwd() }), | ||
__filename, | ||
'absolute path to this file with a basedir resolves' | ||
); | ||
t.equal( | ||
resolve.sync(extensionless, { basedir: process.cwd() }), | ||
__filename, | ||
'extensionless absolute path to this file with a basedir resolves' | ||
); | ||
t.end(); | ||
}); | ||
test('malformed package.json', function (t) { | ||
t.plan(5); | ||
var basedir = path.join(__dirname, 'resolver/malformed_package_json'); | ||
var expected = path.join(basedir, 'index.js'); | ||
t.equal( | ||
resolve.sync('./index.js', { basedir: basedir }), | ||
expected, | ||
'malformed package.json is silently ignored' | ||
); | ||
var res1 = resolve.sync( | ||
'./index.js', | ||
{ | ||
basedir: basedir, | ||
packageFilter: function (pkg, pkgfile, dir) { | ||
t.fail('should not reach here'); | ||
} | ||
} | ||
); | ||
t.equal( | ||
res1, | ||
expected, | ||
'with packageFilter: malformed package.json is silently ignored' | ||
); | ||
var res2 = resolve.sync( | ||
'./index.js', | ||
{ | ||
basedir: basedir, | ||
readPackageSync: function (readFileSync, pkgfile) { | ||
t.equal(pkgfile, path.join(basedir, 'package.json'), 'readPackageSync: `pkgfile` is package.json path'); | ||
var result = String(readFileSync(pkgfile)); | ||
try { | ||
return JSON.parse(result); | ||
} catch (e) { | ||
t.ok(e instanceof SyntaxError, 'readPackageSync: malformed package.json parses as a syntax error'); | ||
} | ||
} | ||
} | ||
); | ||
t.equal( | ||
res2, | ||
expected, | ||
'with readPackageSync: malformed package.json is silently ignored' | ||
); | ||
}); |
var path = require('path'); | ||
var test = require('tape'); | ||
var resolve = require('../'); | ||
var async = require('../async'); | ||
test('`./async` entry point', function (t) { | ||
t.equal(resolve, async, '`./async` entry point is the same as `main`'); | ||
t.end(); | ||
}); | ||
test('async foo', function (t) { | ||
@@ -291,3 +297,3 @@ t.plan(12); | ||
var dir = path.join(__dirname, 'resolver/without_basedir'); | ||
var tester = require(path.join(dir, 'main.js')); | ||
var tester = require(path.join(dir, 'main.js')); // eslint-disable-line global-require | ||
@@ -408,3 +414,3 @@ tester(t, function (err, res, pkg) { | ||
t.ok(err, 'errors on non-string main'); | ||
t.equal(err.message, 'package “invalid main” `main` must be a string'); | ||
t.equal(err.message, 'package “invalid_main” `main` must be a string'); | ||
t.equal(err.code, 'INVALID_PACKAGE_MAIN'); | ||
@@ -422,3 +428,3 @@ t.equal(res, undefined, 'res is undefined'); | ||
t.ok(err, 'errors on non-string main'); | ||
t.equal(err.message, 'package “invalid main” `main` must be a string'); | ||
t.equal(err.message, 'package “invalid_main” `main` must be a string'); | ||
t.equal(err.code, 'INVALID_PACKAGE_MAIN'); | ||
@@ -454,1 +460,91 @@ t.equal(res, undefined, 'res is undefined'); | ||
}); | ||
test('absolute paths', function (t) { | ||
t.plan(4); | ||
var extensionless = __filename.slice(0, -path.extname(__filename).length); | ||
resolve(__filename, function (err, res) { | ||
t.equal( | ||
res, | ||
__filename, | ||
'absolute path to this file resolves' | ||
); | ||
}); | ||
resolve(extensionless, function (err, res) { | ||
t.equal( | ||
res, | ||
__filename, | ||
'extensionless absolute path to this file resolves' | ||
); | ||
}); | ||
resolve(__filename, { basedir: process.cwd() }, function (err, res) { | ||
t.equal( | ||
res, | ||
__filename, | ||
'absolute path to this file with a basedir resolves' | ||
); | ||
}); | ||
resolve(extensionless, { basedir: process.cwd() }, function (err, res) { | ||
t.equal( | ||
res, | ||
__filename, | ||
'extensionless absolute path to this file with a basedir resolves' | ||
); | ||
}); | ||
}); | ||
test('malformed package.json', function (t) { | ||
/* eslint operator-linebreak: ["error", "before"], function-paren-newline: "off" */ | ||
t.plan( | ||
(3 * 3) // 3 sets of 3 assertions in the final callback | ||
+ 2 // 1 readPackage call with malformed package.json | ||
); | ||
var basedir = path.join(__dirname, 'resolver/malformed_package_json'); | ||
var expected = path.join(basedir, 'index.js'); | ||
resolve('./index.js', { basedir: basedir }, function (err, res, pkg) { | ||
t.error(err, 'no error'); | ||
t.equal(res, expected, 'malformed package.json is silently ignored'); | ||
t.equal(pkg, undefined, 'malformed package.json gives an undefined `pkg` argument'); | ||
}); | ||
resolve( | ||
'./index.js', | ||
{ | ||
basedir: basedir, | ||
packageFilter: function (pkg, pkgfile, dir) { | ||
t.fail('should not reach here'); | ||
} | ||
}, | ||
function (err, res, pkg) { | ||
t.error(err, 'with packageFilter: no error'); | ||
t.equal(res, expected, 'with packageFilter: malformed package.json is silently ignored'); | ||
t.equal(pkg, undefined, 'with packageFilter: malformed package.json gives an undefined `pkg` argument'); | ||
} | ||
); | ||
resolve( | ||
'./index.js', | ||
{ | ||
basedir: basedir, | ||
readPackage: function (readFile, pkgfile, cb) { | ||
t.equal(pkgfile, path.join(basedir, 'package.json'), 'readPackageSync: `pkgfile` is package.json path'); | ||
readFile(pkgfile, function (err, result) { | ||
try { | ||
cb(null, JSON.parse(result)); | ||
} catch (e) { | ||
t.ok(e instanceof SyntaxError, 'readPackage: malformed package.json parses as a syntax error'); | ||
cb(null); | ||
} | ||
}); | ||
} | ||
}, | ||
function (err, res, pkg) { | ||
t.error(err, 'with readPackage: no error'); | ||
t.equal(res, expected, 'with readPackage: malformed package.json is silently ignored'); | ||
t.equal(pkg, undefined, 'with readPackage: malformed package.json gives an undefined `pkg` argument'); | ||
} | ||
); | ||
}); |
{ | ||
"name": "invalid main", | ||
"name": "invalid_main", | ||
"main": [ | ||
@@ -4,0 +4,0 @@ "why is this a thing", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128047
95
2789
302
3
10
1
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
Updatedis-core-module@^2.8.0
Updatedpath-parse@^1.0.7