Skip to content

Commit 75eaf94

Browse files
committed
Fail fast if node version is too low
1 parent 7cd418e commit 75eaf94

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

bin/micro.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {resolve} = require('path')
77
const parse = require('minimist')
88
const asyncToGen = require('async-to-gen/register')
99
const updateNotifier = require('update-notifier')
10+
const nodeVersion = require('node-version')
1011

1112
// Ours
1213
const pkg = require('../package')
@@ -38,6 +39,12 @@ if (args.h) {
3839
process.exit(0)
3940
}
4041

42+
// Throw an error if node version is too low
43+
if (nodeVersion.major < 6) {
44+
console.error(`Error! Micro requires at least version 6 of Node. Please upgrade!`)
45+
process.exit(1)
46+
}
47+
4148
if (!file) {
4249
try {
4350
const packageJson = require(resolve(process.cwd(), 'package.json'))
@@ -75,6 +82,7 @@ if (!process.env.NOW && pkg.dist) {
7582
updateNotifier({pkg}).notify()
7683
}
7784

85+
// Load package core with async/await support
7886
const serve = require('../')
7987

8088
let mod

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"isstream": "0.1.2",
6767
"media-typer": "0.3.0",
6868
"minimist": "1.2.0",
69+
"node-version": "^1.0.0",
6970
"raw-body": "2.2.0",
7071
"update-notifier": "^1.0.3"
7172
}

0 commit comments

Comments
 (0)