diff --git a/src/index.ts b/src/index.ts index c80b436d..ec353698 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,8 @@ import yaml from "js-yaml"; import _fs from "fs"; const fs = _fs.promises; +import { SimpleError } from "./SimpleError"; + require("dotenv").config(); 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 import moment from "moment-timezone"; moment.tz.setDefault("UTC");