From 8d4373a9d341f6215d1bfc6c5b385c5aebeafb93 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 4 Dec 2024 16:28:47 -0500 Subject: [PATCH] fixup: define require() in version-check.js --- version-check.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/version-check.js b/version-check.js index 43a0a7ed60..68bfb74a19 100644 --- a/version-check.js +++ b/version-check.js @@ -1,9 +1,13 @@ // This script is supposed to be run in travis to check package version matches -// because of this it is designed to be run on a "clean" git checkout +// because of this it is designed to be run on a "clean" git checkout // this will fail if run after npm install (since npm install updates package-lock) -const packageVersion = require('./package.json').version -const lockVersion = require('./package-lock.json').version +import { createRequire } from 'node:module'; +const require = createRequire(import.meta.url); +const packageVersion = require('./package.json').version; +const lockVersion = require('./package-lock.json').version; if (packageVersion != lockVersion) { - console.log(`version in package.json (${packageVersion}) does not match package-lock.json (${lockVersion})`); + console.log( + `version in package.json (${packageVersion}) does not match package-lock.json (${lockVersion})`, + ); process.exit(1); }