-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run tests on all supported versions of Node.js (#77)
* pin esmock dependency to v2.3 * patch esmock, don't pin version * update comments * run patch in `prepare` script
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @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 works only on Node.js < 19. | ||
// * esmock >= 2.4 works only on Node.js >= 18.6. | ||
// If we are running Node.js < 19, replace the esmock dependency with the legacy release. | ||
// 111 is the ABI version number of Node.js 19: https://nodejs.org/en/download/releases | ||
if (process.versions.modules < 111) { | ||
(async () => { | ||
try { | ||
await fs.access("node_modules/esmock_legacy"); | ||
} catch { | ||
return; | ||
} | ||
await fs.rmdir("node_modules/esmock", { recursive: true }); | ||
await fs.rename("node_modules/esmock_legacy", "node_modules/esmock"); | ||
})(); | ||
} |