Skip to content

Commit

Permalink
👽 Valid node version
Browse files Browse the repository at this point in the history
fix #69
  • Loading branch information
bchatard committed Oct 31, 2019
1 parent 379f922 commit 053f00f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Requirements

You need [Node.js 8+](https://nodejs.org) and [Alfred 3.5+](https://www.alfredapp.com) with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.
You need [Node.js 8.12+/9.7+](https://nodejs.org) and [Alfred 3.5+](https://www.alfredapp.com) with the paid [Powerpack](https://www.alfredapp.com/powerpack/) upgrade.

This workflow need one of JetBrains products (**2019.1+**), and its [shell script](#init-shell-script) to works

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"husky": "3.0.9",
"pretty-quick": "2.0.0"
},
"engines": {
"node": "^8.12.0 || >=9.7.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const alfy = require("alfy");

// check node version
const majorVersion = Number(process.version.replace("v", "").split(".")[0]);
if (majorVersion < 8) {
alfy.error(`Wrong Node version. We need v8+, you have ${process.version}`);
if (!require("./version_checker").check()) {
return;
}

Expand Down
21 changes: 21 additions & 0 deletions src/version_checker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const alfy = require("alfy");

// check node version
const version = process.version.replace("v", "").split(".");
const majorVersion = Number(version[0]);
const minorVersion = Number(version[1]);

exports.check = () => {
if (
majorVersion < 8 || // at least v8
(majorVersion === 8 && minorVersion < 12) || // at least 8.12
(majorVersion === 9 && minorVersion < 7) // at least 9.7
) {
alfy.error(
`Wrong Node version. We need v8.12+, 9.7+ or newer, you have ${process.version}`
);
return false;
}

return true;
};

0 comments on commit 053f00f

Please sign in to comment.