extensionless
Advanced tools
Comparing version 1.4.1 to 1.4.2
{ | ||
"name": "extensionless", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,23 +0,4 @@ | ||
import {readFileSync, stat} from 'fs' | ||
import {dirname, extname, isAbsolute, join} from 'path' | ||
import {argv, cwd} from 'process' | ||
import {extname, isAbsolute} from 'path' | ||
import {lookFor} from './config.js' | ||
let pkgJson, curDir, upDir = isAbsolute(argv[1] ?? '') ? argv[1] : cwd() | ||
do { | ||
try { | ||
pkgJson = JSON.parse(readFileSync(join(curDir = upDir, 'package.json'), 'utf8')) | ||
} catch (e) { | ||
if (!['ENOTDIR', 'ENOENT', 'EISDIR'].includes(e.code)) throw e | ||
} | ||
} while (!pkgJson && curDir !== (upDir = dirname(curDir))) | ||
let { | ||
lookFor = ['js'] | ||
} = pkgJson?.extensionless ?? {} | ||
Array.isArray(lookFor) && lookFor.length && lookFor.every(a => typeof a === 'string' && /^[a-z]+\w*$/i.test(a)) || ( | ||
console.error('\n❌ \x1b[31m%s\x1b[0m', `Error: The package.json field 'extensionless.lookFor' must be an array of alphanumeric strings!`), | ||
process.exit(1) | ||
) | ||
let indexFiles = [lookFor.map(e => `index.${e}`), ['index.json']] | ||
@@ -40,7 +21,5 @@ let candidates = indexFiles.map(i => i.map(f => extname(f)).concat(i.map(f => `/${f}`))) | ||
for (let postfix of postfixes[+(importAssertions?.type === 'json')]) { | ||
let testURL = selfURL + postfix | ||
if ((await new Promise(r => stat(new URL(testURL), (_, s) => r(s))))?.isFile()) { | ||
return await nextResolve(testURL) | ||
} | ||
try { | ||
return await nextResolve(selfURL + postfix) | ||
} catch {} | ||
} | ||
@@ -47,0 +26,0 @@ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
5782
5
47