From 697a9efbc9b543ee908438284739fa3bc2f0e3ad Mon Sep 17 00:00:00 2001 From: Ben Lowery Date: Tue, 8 Dec 2015 12:53:48 -0500 Subject: [PATCH] Add a check to verify that the node version is proper --- Makefile | 9 ++++++--- bin/check-node-version | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 bin/check-node-version diff --git a/Makefile b/Makefile index 5794d0cc15ccf4..ce980d06bc0a9c 100644 --- a/Makefile +++ b/Makefile @@ -56,14 +56,17 @@ install: node_modules run: welcome githooks-commit install build @$(NODE) build/bundle-$(CALYPSO_ENV).js +node-version: + @$(BIN)/check-node-version + # a helper rule to ensure that a specific module is installed, # without relying on a generic `npm install` command -node_modules/%: +node_modules/%: node-version @$(NPM) install $(notdir $@) # ensures that the `node_modules` directory is installed and up-to-date with # the dependencies listed in the "package.json" file. -node_modules: package.json +node_modules: package.json node-version @$(NPM) prune @$(NPM) install @touch node_modules @@ -157,5 +160,5 @@ githooks-push: FORCE: .PHONY: build build-development build-server -.PHONY: run install test clean distclean translate route +.PHONY: run install test clean distclean translate route node-version .PHONY: githooks githooks-commit githooks-push diff --git a/bin/check-node-version b/bin/check-node-version new file mode 100755 index 00000000000000..c574acad93404a --- /dev/null +++ b/bin/check-node-version @@ -0,0 +1,8 @@ +#!/usr/bin/env node +const requiredVersion = require( '../package' ).engines.node, + semver = require( 'semver' ); + +if ( ! semver.satisfies( process.version, requiredVersion ) ) { + console.error( 'wp-calypso requires node ' + requiredVersion + '. Please upgrade! See https://nodejs.org for instructions.' ); + process.exitCode = 1; +}