Skip to content

Commit

Permalink
🛠 Add postinstall script to check node version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastel committed Oct 8, 2019
1 parent 7a36250 commit 490eeac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ For example _student_ FSM:
4. Press the submit button and enjoy
---

### Notes
1. We recommend you to use nodejs of version 10 or lower. If you using any of features that does not supported by node v10, score won't be submitted.
2. Please be sure that each of your test in limit of 30sec.


© [humanamburu](https://github.com/humanamburu)
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
"description": "",
"scripts": {
"test": "mocha -r ./test/setup-mocha.js --colors",
"start": "webpack-dev-server"
"start": "webpack-dev-server",
"postinstall": "node postinstall.js"
},
"author": "humanamburu",
"license": "ISC",
"engines": {
"node": "<=10"
},
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.0.2",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"colors": "^1.4.0",
"semver": "^6.3.0"
}
}
13 changes: 13 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const semver = require('semver');
const colors = require('colors/safe');

const { engines: { node: nodeVersion }} = require('./package');

if (!semver.satisfies(process.version, nodeVersion)) {
process.emitWarning(
colors.red(`
For this task we are strictly recomend you to use node ${nodeVersion}.
Now you are using node ${process.version}, if you are using any of features that not supported by node ${nodeVersion}, score won't be submitted
`)
);
}

0 comments on commit 490eeac

Please sign in to comment.