Socket
Book a DemoInstallSign in
Socket

eshost

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eshost - npm Package Compare versions

Comparing version

to
4.4.0

17

lib/ConsoleAgent.js

@@ -11,3 +11,3 @@ 'use strict';

const inception = require('./inception');
const {getDependencies, rawSource} = require('./dependencies.js');
const {getDependencies, hasModuleSpecifier, rawSource} = require('./dependencies.js');
const writeSources = require('./write-sources.js');

@@ -35,3 +35,3 @@

evalScript(code, options = {}) {
evalScript(code /*, options = {} */) {
let tempfile = temp.path({ suffix: '.js' });

@@ -66,8 +66,4 @@ let temppath = path.dirname(tempfile);

let isEarlySyntaxError = (phase === 'early' || phase === 'parse') && type === 'SyntaxError';
let sourcebase = path.basename(file);
let sourcebase = path.basename(file);
// When testing code that which has the "module" flag,
// we must copy the test file with its actual name because the
// source may attempt to import itself by that name.
tempfile = path.join(temppath, sourcebase);
// If the main test file isn't a negative: SyntaxError,

@@ -77,3 +73,2 @@ // then we can proceed with checking for importable files

dependencies.push(...getDependencies(file, [sourcebase]));
hasDependencies = dependencies.length > 0;

@@ -85,4 +80,10 @@ }

hasDependencies = false;
// When testing module or dynamic import code that imports itself,
// we must copy the test file with its actual name.
}
if (hasModuleSpecifier(contents)) {
tempfile = path.join(temppath, sourcebase);
}
// The test record in "code" is no longer needed and

@@ -89,0 +90,0 @@ // all further operations expect the "code" argument to be

@@ -7,2 +7,7 @@ 'use strict';

function hasModuleSpecifier(source) {
return /(import|import\(|from)(\s*)'(.*)'|"(.*)";/g.test(source);
}
function findModuleSpecifiers(source) {

@@ -32,3 +37,3 @@ // While it would be ideal to parse the source to an AST

let basename = path.basename(file);
let contents;
let contents = '';

@@ -38,17 +43,23 @@ if (rawSourceCache.has(basename)) {

} else {
contents = fs.readFileSync(file, 'utf8');
rawSourceCache.set(basename, contents);
try {
contents = fs.readFileSync(file, 'utf8');
rawSourceCache.set(basename, contents);
} catch (error) {
accum.splice(accum.indexOf(basename), 1);
}
}
let specifiers = findModuleSpecifiers(contents);
if (contents.length) {
let specifiers = findModuleSpecifiers(contents);
if (!specifiers.length) {
return [basename];
}
if (!specifiers.length) {
return [basename];
}
for (let specifier of specifiers) {
if (!accum.includes(specifier)) {
accum.push(specifier);
if (basename !== specifier) {
accum.push(...getDependencies(path.join(dirname, specifier), accum));
for (let specifier of specifiers) {
if (!accum.includes(specifier)) {
accum.push(specifier);
if (basename !== specifier) {
accum.push(...getDependencies(path.join(dirname, specifier), accum));
}
}

@@ -63,2 +74,3 @@ }

getDependencies,
hasModuleSpecifier,
rawSource: {

@@ -65,0 +77,0 @@ get(file) {

{
"name": "eshost",
"version": "4.3.0",
"version": "4.4.0",
"description": "Invoke ECMAScript scripts in any command line JS engine.",

@@ -5,0 +5,0 @@ "main": "lib/eshost.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.