Skip to content

Commit

Permalink
Add a check to verify that the node version is proper
Browse files Browse the repository at this point in the history
  • Loading branch information
blowery authored and aduth committed Dec 8, 2015
1 parent 607ff17 commit 697a9ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions bin/check-node-version
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 697a9ef

Please sign in to comment.