New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

setup-env

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

setup-env - npm Package Compare versions

Comparing version
1.2.6
to
2.0.0
+9
-0
CHANGELOG.md
# CHANGELOG
# 2.0.0
- Apply #3, but fix the issue that is introduced by it. Which is a React
specific bug that will prevent your process from closing because it
detects the `MessageChannel` object and uses that for scheduling but never
releases resources.
- Silence JSDOM warnings about getComputedStyle, we get it, the 2nd prop
doesn't exist, but you shouldn't be flooding the console on each activation.
# 1.2.6

@@ -4,0 +13,0 @@

+9
-4

@@ -58,8 +58,13 @@ const diagnostics = require('diagnostics');

'register', // Setup @babel/register.
'enzyme', // Configure enzyme Adapter.
'jsdom', // Prepare enviroment for { mount } support.
//
// Note to future self: The order here somehow matters, when this is
// switched with enzyme, CI, and tests will not exit cleanly.
// Note to future self, if CI tests do not work, it's because they are not
// getting cleaned up correctly. The reason that enzyme needs to be loaded
// after JSDOM is so it doesn't override event handlers that might be
// needed for testing. This affects different version of JSDOM, older
// versions like 17 might be fine, but newer versions like JSDOM 20 do
// miss event handlers like .attachEvent
//
'jsdom', // Prepare enviroment for { mount } support.
'enzyme', // Configure enzyme Adapter.
'static', // Allow require of static assets in Node.js.

@@ -66,0 +71,0 @@ 'assert' // Introduce plugins to assert frameworks.

/**
* Apply additional patches to the JSDOM environment.
*
* @returns {Undefined} Absolutely nothing.
*/
function patch() {
const { window } = global;
//
// JSDOM doesn't support the 2nd argument of getComputedStyle and throws a
// Not implemented error, while it's true that is not functional, this
// thrown errors and breaks test suites for no reason.
//
const errors = [];
const error = console.error;
console.error = (e) => errors.push(e);
try {
window.getComputedStyle(document.body, ':after');
} catch (_) {}
console.error = error;
if (errors.length && errors[0].includes('Not implemented: window.computedStyle(elt, pseudoElt)')) {
const { getComputedStyle } = window;
window.getComputedStyle = (elt) => getComputedStyle(elt);
}
//
// Ayo what is going on here you might ask, well lmao, your node process
// will freeze if you use JSDOM, React, and node with some very specific
// versioning conditions.
//
// https://github.com/facebook/react/issues/20756
//
// The only solution is to just nuke it.
//
try {
const version = require('react').version.split('.');
if (+version[0] < 17 || (+version[0] === 17 && +version[1] < 1)) {
delete global.MessageChannel;
}
} catch (_) {}
}
/**
* But y tho:

@@ -16,3 +61,3 @@ *

debug('Enviroment already has a window & document global, ignoring jsdom');
return;
return patch();
}

@@ -37,3 +82,3 @@

debug('Enviroment already has a window & document global, ignoring jsdom');
return;
return patch();
}

@@ -87,2 +132,4 @@

);
patch();
};
{
"name": "setup-env",
"version": "1.2.6",
"version": "2.0.0",
"description": "Automated, feature detected, environment setup for your test suite",

@@ -50,3 +50,3 @@ "main": "index.js",

"enzyme-adapter-react-16": "^1.14.0",
"jsdom": "^15.1.1",
"jsdom": "^20.0.0",
"mocha": "^6.1.4",

@@ -53,0 +53,0 @@ "nyc": "^14.1.1",