Skip to content

Commit a323001

Browse files
authored
Check for node version in postinstall script (#4657)
Added open collective as a bonus. I notice a lot of user still fork parse-server-example. They then update to the latest version but their engines.node in package.json stays the same. This will output directions to support latest version.
1 parent 6abf29d commit a323001

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"test": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 TESTING=1 jasmine",
7474
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.2.6} MONGODB_STORAGE_ENGINE=mmapv1 TESTING=1 nyc jasmine",
7575
"start": "node ./bin/parse-server",
76-
"prepublish": "npm run build"
76+
"prepublish": "npm run build",
77+
"postinstall": "node -p 'require(\"./postinstall.js\")()'"
7778
},
7879
"engines": {
7980
"node": ">=6.11.4"

postinstall.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const pkg = require('./package.json');
2+
3+
const version = parseFloat( process.version.substr(1) );
4+
const minimum = parseFloat( pkg.engines.node.match(/\d+/g).join('.') );
5+
6+
module.exports = function () {
7+
const openCollective = `
8+
1111111111
9+
1111111111111111
10+
1111111111111111111111
11+
11111111111111111111111111
12+
111111111111111 11111111
13+
1111111111111 111111
14+
1111111111111 111111111 111111
15+
111111111111 11111111111 111111
16+
1111111111111 11111111111 111111
17+
1111111111111 1111111111 111111
18+
1111111111111111111111111 1111111
19+
11111111 11111111
20+
111111 1111111111111111111
21+
11111 11111 111111111111111111
22+
11111 11111111111111111
23+
111111 111111111111111111
24+
11111111111111111111111111
25+
1111111111111111111111
26+
111111111111111111
27+
11111111111
28+
29+
30+
Thanks for installing parse 🙏
31+
Please consider donating to our open collective
32+
to help us maintain this package.
33+
34+
👉 https://opencollective.com/parse-server
35+
36+
`;
37+
process.stdout.write(openCollective);
38+
if (version >= minimum) {
39+
process.exit(0);
40+
}
41+
42+
const errorMessage = `
43+
⚠️ parse-server requires at least node@${minimum}!
44+
You have node@${version}
45+
46+
`;
47+
48+
process.stdout.write(errorMessage);
49+
process.exit(1);
50+
};

0 commit comments

Comments
 (0)