Skip to content

Commit d0bd284

Browse files
committed
🛠 Add postinstall script to check node version
1 parent 37654a2 commit d0bd284

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

‎README.md

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Should return index of specified value or -1 if list doesn't contain such
5757

5858
---
5959

60+
### Notes
61+
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.
62+
2. Please be sure that each of your test in limit of 30sec.
63+
6064
---
6165

6266
© [Shastel](https://github.com/Shastel)

‎package-lock.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
"description": "",
55
"scripts": {
66
"test": "mocha -r ./test/setup-mocha.js",
7-
"start": "webpack-dev-server"
7+
"start": "webpack-dev-server",
8+
"postinstall": "node postinstall.js"
89
},
910
"author": "",
11+
"engines": {
12+
"node": "<=10"
13+
},
1014
"license": "ISC",
1115
"devDependencies": {
1216
"chai": "^3.5.0",
@@ -15,5 +19,9 @@
1519
"sinon-chai": "^2.8.0",
1620
"webpack": "^1.13.1",
1721
"webpack-dev-server": "^1.14.1"
22+
},
23+
"dependencies": {
24+
"colors": "^1.4.0",
25+
"semver": "^6.3.0"
1826
}
1927
}

‎postinstall.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const semver = require('semver');
2+
const colors = require('colors/safe');
3+
4+
const { engines: { node: nodeVersion }} = require('./package');
5+
6+
if (!semver.satisfies(process.version, nodeVersion)) {
7+
process.emitWarning(
8+
colors.red(`
9+
For this task we are strictly recomend you to use node ${nodeVersion}.
10+
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
11+
`)
12+
);
13+
}

0 commit comments

Comments
 (0)