Skip to content

Commit f538c1d

Browse files
committed
don't show postinstall msg when SUPPRESS_SUPPORT env is set
1 parent 0b0270b commit f538c1d

File tree

3 files changed

+51
-32
lines changed

3 files changed

+51
-32
lines changed

package-lock.json

Lines changed: 21 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fast-xml-parser",
3-
"version": "3.12.13",
3+
"version": "3.12.14",
44
"description": "Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries",
55
"main": "./src/parser.js",
66
"scripts": {
@@ -10,7 +10,7 @@
1010
"bundle": "webpack && webpack --config webpack-prod.config.js",
1111
"coverage": "istanbul cover -x \"cli.js\" -x \"spec/*spec.js\" jasmine spec/*spec.js;",
1212
"coverage:check": "istanbul check-coverage --branch 90 --statement 90",
13-
"postinstall": "node tasks/postinstall.js",
13+
"postinstall": "node tasks/postinstall.js || exit 0",
1414
"prettier": "prettier --write src/**/*.js"
1515
},
1616
"bin": {

tasks/postinstall.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
// Display message after instalation
1+
#!/usr/bin/env node
22

3-
const stars = '\x1B[1m***\x1B[0m';
4-
const yellow = '\033[1;33m';
5-
// const light_green = "\033[1;32m";
6-
const light_blue = '\033[1;34m';
7-
const NC = '\033[0m'; // No Color
3+
function main() {
4+
if (process.env.SUPPRESS_SUPPORT) {
5+
return;
6+
}
87

9-
console.log('' + stars + ' Thank you for using fast-xml-parser! ' + stars);
10-
console.log('');
11-
console.log(yellow + 'Donating to an open source project is more affordable' + NC);
12-
console.log(light_blue + ' https://opencollective.com/fast-xml-parser/donate' + NC);
13-
console.log(light_blue + ' https://www.patreon.com/bePatron?u=9531404' + NC);
14-
console.log(light_blue + ' https://www.paypal.me/amitkumarguptagwl' + NC);
15-
console.log('');
16-
console.log('');
17-
process.exit(0);
8+
const msg = '\u001b[32mLove fast-xml-parser? You can now support the project on following:\u001b[22m\u001b[39m\n > \u001b[96m\u001b[1mhttps://opencollective.com/fast-xml-parser/donate\u001b[0m\n > \u001b[96m\u001b[1mhttps://www.patreon.com/bePatron?u=9531404\u001b[0m\n';
9+
try {
10+
const Configstore = require('configstore');
11+
const pkg = require(__dirname + '/../package.json');
12+
const now = Date.now();
13+
14+
var week = 1000 * 60 * 60 * 24 * 7;
15+
16+
// create a Configstore instance with an unique ID e.g.
17+
// Package name and optionally some default values
18+
const conf = new Configstore(pkg.name);
19+
const last = conf.get('lastCheck');
20+
21+
if (!last || now - week > last) {
22+
console.log(msg);
23+
conf.set('lastCheck', now);
24+
}
25+
} catch (e) {
26+
console.log(msg);
27+
}
28+
}
29+
30+
main();

0 commit comments

Comments
 (0)