Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extensionless

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extensionless - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

src/config.js

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc