Skip to content

Commit

Permalink
wp-now: Error if node doesn't meet the minimum required version (#434)
Browse files Browse the repository at this point in the history
Fixes #429

## What?

Exits with an error if node doesn't meet the minimum required version.

```
$ wp-now
You are running Node.js version 14, but this application requires at least Node.js 18. Please upgrade your Node.js version.
```

## Why?

Without this, `wp-now` fails cryptically and provides no context for how
it fails.

## Testing Instructions

TBD
  • Loading branch information
danielbachhuber authored May 25, 2023
1 parent 1eefd6e commit f38d888
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/wp-now/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import { runCli } from './run-cli';

const requiredMajorVersion = 18;

const currentNodeVersion = parseInt(process.versions.node.split('.')[0]);

if (currentNodeVersion < requiredMajorVersion) {
console.error(
`You are running Node.js version ${currentNodeVersion}, but this application requires at least Node.js ${requiredMajorVersion}. Please upgrade your Node.js version.`
);
process.exit(1);
}

runCli();

0 comments on commit f38d888

Please sign in to comment.