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 1bce01e commit e1fa8d2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ Write your solution in `src/index.js`
1. Open [rs app](https://app.rs.school) and login
2. Go to [submit task page](https://app.rs.school/course/submit-task?course=rs-2019-q3)
3. Select your task (morse-decoder)
4. Press the submit button and enjoy
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.
18 changes: 18 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,7 +4,11 @@
"description": "Morse code decoder",
"main": "test.js",
"scripts": {
"test": "mocha test.js"
"test": "mocha test.js",
"postinstall": "node postinstall.js"
},
"engines": {
"node": "<=10"
},
"repository": {
"type": "git",
Expand All @@ -19,5 +23,9 @@
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^6.2.0"
},
"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 e1fa8d2

Please sign in to comment.