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

es-main

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-main - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

9

main.js
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) {

5

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

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