Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Check if NodeJS version is compatible before running any command
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Feb 25, 2015
1 parent 74bbf1f commit e5851b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bin/gh.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@

var path = require('path'),
fs = require('fs'),
logger = require('../lib/logger'),
pkg = require('../package.json'),
semver = require('semver'),
tracker = require('../lib/tracker'),
configs = require('../lib/configs');

// Check node version
if (!isCompatibleNodeVersion()) {
logger.error('Please update your NodeJS version: http://nodejs.org/download');
}

if (!fs.existsSync(configs.getUserHomePath())) {
configs.createGlobalConfig();
}
Expand All @@ -25,12 +33,16 @@ if (configs.getConfig()[configs.PLUGINS_PATH_KEY] === undefined) {
configs.getNodeModulesGlobalPath();
}

// -- Env ------------------------------------------------------------------------------------------
try {
// -- Env ------------------------------------------------------------------------------------------
process.env.GH_PATH = path.join(__dirname, '../');

require('../lib/cmd.js').run();
} catch (e) {
tracker.track('error');
throw e;
}

function isCompatibleNodeVersion() {
return semver.satisfies(process.version, pkg.engines.node);
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"moment": "^2.9.0",
"nopt": "^3.0.1",
"open": "^0.0.5",
"semver": "^4.3.1",
"truncate": "^1.0.2",
"update-notifier": "^0.3.0",
"userhome": "^1.0.0",
Expand Down

0 comments on commit e5851b7

Please sign in to comment.