Verify required Node.js version
This commit is contained in:
parent
2e30a3b9e7
commit
42f45af499
1 changed files with 12 additions and 0 deletions
12
src/index.ts
12
src/index.ts
|
@ -4,6 +4,8 @@ import yaml from "js-yaml";
|
||||||
import _fs from "fs";
|
import _fs from "fs";
|
||||||
const fs = _fs.promises;
|
const fs = _fs.promises;
|
||||||
|
|
||||||
|
import { SimpleError } from "./SimpleError";
|
||||||
|
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
|
||||||
process.on("unhandledRejection", (reason, p) => {
|
process.on("unhandledRejection", (reason, p) => {
|
||||||
|
@ -22,6 +24,16 @@ process.on("uncaughtException", err => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Verify required Node.js version
|
||||||
|
const REQUIRED_NODE_VERSION = "10.14.2";
|
||||||
|
const requiredParts = REQUIRED_NODE_VERSION.split(".").map(v => parseInt(v, 10));
|
||||||
|
const actualVersionParts = process.versions.node.split(".").map(v => parseInt(v, 10));
|
||||||
|
for (const [i, part] of actualVersionParts.entries()) {
|
||||||
|
if (part < requiredParts[i]) {
|
||||||
|
throw new SimpleError(`Unsupported Node.js version! Must be at least ${REQUIRED_NODE_VERSION}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Always use UTC
|
// Always use UTC
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
moment.tz.setDefault("UTC");
|
moment.tz.setDefault("UTC");
|
||||||
|
|
Loading…
Add table
Reference in a new issue