Skip to content

Commit

Permalink
feat: report error and fail for unsupported NodeJS versions (#1984) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy authored Dec 18, 2021
1 parent 9f65b44 commit 52bb33e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cspell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"get-stdin": "^8.0.0",
"glob": "^7.2.0",
"imurmurhash": "^0.1.4",
"semver": "^7.3.5",
"strip-ansi": "^6.0.1",
"vscode-uri": "^3.0.2"
},
Expand All @@ -96,6 +97,7 @@
"@types/imurmurhash": "^0.1.1",
"@types/micromatch": "^4.0.2",
"@types/minimatch": "^3.0.5",
"@types/semver": "^7.3.9",
"jest": "^27.4.5",
"micromatch": "^4.0.4",
"minimatch": "^3.0.4",
Expand Down
8 changes: 8 additions & 0 deletions packages/cspell/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as commander from 'commander';
import * as path from 'path';
import * as semver from 'semver';
import { commandCheck } from './commandCheck';
import { commandLink } from './commandLink';
import { commandLint } from './commandLint';
import { commandTrace } from './commandTrace';
import { ApplicationError } from './util/errors';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const npmPackage = require(path.join(__dirname, '..', 'package.json'));

Expand All @@ -18,6 +20,12 @@ export async function run(program?: commander.Command, argv?: string[]): Promise

prog.version(npmPackage.version).description('Spelling Checker for Code').name('cspell');

if (!semver.satisfies(process.versions.node, npmPackage.engines.node)) {
throw new ApplicationError(
`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`
);
}

commandLint(prog);
commandTrace(prog);
commandCheck(prog);
Expand Down

0 comments on commit 52bb33e

Please sign in to comment.