Created
March 23, 2024 11:20
-
-
Save knocte/f78f8f60800e54bce59110138389105b to your computer and use it in GitHub Desktop.
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
diff --git a/@commitlint/cli/src/cli.ts b/@commitlint/cli/src/cli.ts | |
index b58c047b..39e9acac 100644 | |
--- a/@commitlint/cli/src/cli.ts | |
+++ b/@commitlint/cli/src/cli.ts | |
@@ -24,6 +24,8 @@ import {CliError} from './cli-error.js'; | |
const require = createRequire(import.meta.url); | |
+const process = require('node:process'); | |
+ | |
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..'); | |
const dynamicImport = async <T>(id: string): Promise<T> => { | |
@@ -191,6 +193,20 @@ async function resolveArgs(args: MainArgs): Promise<MainArgsObject> { | |
} | |
async function main(args: MainArgs): Promise<void> { | |
+ if (process !== null) { | |
+ let runningOnNode = Object.hasOwn(process, "versions") && Object.hasOwn(process.versions, "node"); | |
+ if (runningOnNode) { | |
+ | |
+ let nodeVersion = process.versions.node as string; | |
+ if (nodeVersion.indexOf(".") > 0) { | |
+ let nodeJsMajorVersion = parseInt(nodeVersion.split('.')[0], 10); | |
+ if (nodeJsMajorVersion < 18) { | |
+ throw new Error("Your version of NodeJS is too old, and not supported by commitlint; please upgrade"); | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
const options = await resolveArgs(args); | |
if (typeof options.edit === 'undefined') { | |
options.edit = false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment