Comparing version 1.1.1 to 1.2.0
import path from 'path'; | ||
import process from 'process'; | ||
import {createRequire} from 'module'; | ||
import {fileURLToPath} from 'url'; | ||
@@ -26,5 +27,11 @@ | ||
export default function esMain(meta) { | ||
if (!meta || !process.argv[1]) { | ||
return false; | ||
} | ||
const require = createRequire(meta.url); | ||
const scriptPath = require.resolve(process.argv[1]); | ||
const modulePath = fileURLToPath(meta.url); | ||
const scriptPath = process.argv[1]; | ||
const extension = path.extname(scriptPath); | ||
@@ -31,0 +38,0 @@ if (extension) { |
{ | ||
"name": "es-main", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Test if an ES module is run directly (require.main replacement)", | ||
@@ -25,2 +25,5 @@ "main": "main.js", | ||
"test:without-node": "./test.js", | ||
"test:resolve-index": "node test-resolve-index", | ||
"test:resolve-main": "node test-resolve-main", | ||
"test:repl": "node --eval \"import('./main.js').then(mod => {if (mod.default({})) throw new Error('expected false')})\"", | ||
"test:types": "npx tsc --noEmit", | ||
@@ -27,0 +30,0 @@ "test": "npm-run-all test:*" |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
4168
48
2