Skip to content

Commit

Permalink
patch esmock, don't pin version
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Oct 23, 2023
1 parent b3ae69b commit e7c10b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"scripts": {
"lint": "eslint . --report-unused-disable-directives",
"postinstall": "node tests/patch-esmock.js",
"release:generate:latest": "eslint-generate-release",
"release:generate:alpha": "eslint-generate-prerelease alpha",
"release:generate:beta": "eslint-generate-prerelease beta",
Expand Down Expand Up @@ -58,7 +59,8 @@
"eslint": "^8.48.0",
"eslint-config-eslint": "^9.0.0",
"eslint-release": "^3.2.0",
"esmock": "~2.3.8",
"esmock": "^2.5.8",
"esmock_legacy": "npm:esmock@~2.3.8",
"espree": "^9.0.0",
"globals": "^13.21.0",
"lint-staged": "^12.1.2",
Expand Down
15 changes: 15 additions & 0 deletions tests/patch-esmock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @fileoverview Run by npm to replace esmock with a legacy release on older versions of Node.js.
* @author Francesco Trotta
*/

import { promises as fs } from "fs";

// esmock < 2.4 supports only Node.js < 19. esmock >= 2.4 supports only Node.js >= 18.6.
// If we are running Node.js < 19, replace the esmock dependency with the legacy release.
if (process.versions.modules < 111) {
(async () => {
await fs.rmdir("node_modules/esmock", { recursive: true });
await fs.rename("node_modules/esmock_legacy", "node_modules/esmock");
})();
}

0 comments on commit e7c10b0

Please sign in to comment.