diff --git a/package.json b/package.json index ac63c9d..a11f179 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ } }, "engines": { - "node": ">=14" + "node": ">=14.6" }, "publishConfig": { "access": "public" diff --git a/src/create.ts b/src/create.ts index 471458a..826cf93 100644 --- a/src/create.ts +++ b/src/create.ts @@ -8,9 +8,15 @@ import { validFilename } from './utils/fs' import { cli } from './utils/cli' +import { currentVersion, requiredVersion, validNodeVersion } from './utils/node' import { error, log, success, warn } from './utils/log' export const init = () => { + if (!validNodeVersion()) { + error(`You are running Node ${currentVersion}.\nThis package requires Node ${requiredVersion} or higher.\nPlease update your version of Node.`) + return + } + if (Object.keys(cli).length <= 3 && cli._.length === 0) { const cmd = pc.cyan(`${cli.$0} --help`) warn(`No filenames provided. Use the command "${cmd}" for help`) diff --git a/src/utils/node.ts b/src/utils/node.ts new file mode 100644 index 0000000..0a0c37b --- /dev/null +++ b/src/utils/node.ts @@ -0,0 +1,9 @@ +export const currentVersion = process.versions.node + +export const requiredVersion = 14 + +export const validNodeVersion = () => { + const semver = currentVersion.split('.') + const major = semver[0] + return Number(major) >= requiredVersion +}