Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const colors = require('chalk');
const pkg = require('./package.json');

const version = parseFloat( process.version.substr(1) );
const minimum = parseFloat( pkg.engines.node.match(/\d+/g).join('.') );

module.exports = function () {
if (version >= minimum) {
return true;
}

const errorMessage = colors.yellow(`

⚠️ preact-cli requires at least node@${minimum}!
You have node@${version}

`);

// version not supported && exit
process.stdout.write(errorMessage) + '\n';
process.exit(1);
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dev": "babel-node src",
"lint": "eslint src tests",
"pretest": "npm run -s build",
"postinstall": "node check.js",
"test": "tape -r babel-register tests/*.test.js | tap-diff",
"test:build": "babel-node src build --cwd examples/root",
"test:serve": "npm run -s test:build && babel-node src serve --port 3000 --cwd examples/root",
Expand All @@ -27,7 +28,8 @@
},
"files": [
"lib",
"examples"
"examples",
"check.js"
],
"keywords": [
"preact",
Expand Down Expand Up @@ -115,8 +117,8 @@
"es6-promisify": "^5.0.0",
"file-loader": "^0.11.1",
"fs.promised": "^3.0.0",
"html-webpack-plugin": "^2.28.0",
"html-webpack-exclude-assets-plugin": "0.0.5",
"html-webpack-plugin": "^2.28.0",
"isomorphic-unfetch": "^2.0.0",
"json-loader": "^0.5.4",
"less": "^2.7.2",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import serve from './commands/serve';
import installHooks from './lib/output-hooks';
import pkg from '../package.json';
import logo from './lib/logo';
import checkVersion from './../check';

global.Promise = require('promise-polyfill');

checkVersion();

installHooks();

yargs
Expand Down