Skip to content

Commit

Permalink
Fail fast if node version is too low
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Feb 4, 2017
1 parent 7cd418e commit 75eaf94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/micro.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {resolve} = require('path')
const parse = require('minimist')
const asyncToGen = require('async-to-gen/register')
const updateNotifier = require('update-notifier')
const nodeVersion = require('node-version')

// Ours
const pkg = require('../package')
Expand Down Expand Up @@ -38,6 +39,12 @@ if (args.h) {
process.exit(0)
}

// Throw an error if node version is too low
if (nodeVersion.major < 6) {
console.error(`Error! Micro requires at least version 6 of Node. Please upgrade!`)
process.exit(1)
}

if (!file) {
try {
const packageJson = require(resolve(process.cwd(), 'package.json'))
Expand Down Expand Up @@ -75,6 +82,7 @@ if (!process.env.NOW && pkg.dist) {
updateNotifier({pkg}).notify()
}

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

let mod
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"isstream": "0.1.2",
"media-typer": "0.3.0",
"minimist": "1.2.0",
"node-version": "^1.0.0",
"raw-body": "2.2.0",
"update-notifier": "^1.0.3"
}
Expand Down

0 comments on commit 75eaf94

Please sign in to comment.