Skip to content

Commit ee2aac1

Browse files
authored
fix: support env.SUPPRESS_SUPPORT (#1334)
Show request for help once a week/install and support process.env.SUPPRESS_SUPPORT to hide entirely.
1 parent 58b82f2 commit ee2aac1

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

bin/postinstall.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
3+
function main() {
4+
if (process.env.SUPPRESS_SUPPORT) {
5+
return;
6+
}
7+
8+
try {
9+
const Configstore = require('configstore');
10+
const pkg = require(__dirname + '/../package.json');
11+
const now = Date.now();
12+
13+
var week = 1000 * 60 * 60 * 24 * 7;
14+
15+
// create a Configstore instance with an unique ID e.g.
16+
// Package name and optionally some default values
17+
const conf = new Configstore(pkg.name);
18+
const last = conf.get('lastCheck');
19+
20+
if (!last || now - week > last) {
21+
console.log('\u001b[32mLove nodemon? You can now support the project via the open collective:\u001b[22m\u001b[39m\n > \u001b[96m\u001b[1mhttps://opencollective.com/nodemon/donate\u001b[0m\n');
22+
conf.set('lastCheck', now);
23+
}
24+
} catch (e) {
25+
console.log('\u001b[32mLove nodemon? You can now support the project via the open collective:\u001b[22m\u001b[39m\n > \u001b[96m\u001b[1mhttps://opencollective.com/nodemon/donate\u001b[0m\n');
26+
}
27+
}
28+
29+
main();

faq.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ For example, [email protected] will exit with `2` on failing tests. To handle the exit c
4040
nodemon -x 'mocha test/bad.test.js || exit 1'
4141
```
4242

43+
# You want to suppress the request for support message
44+
45+
Perhaps you're [already supporting nodemon](https://opencollective.com/nodemon) or you're using it in CI and it needs to be quietened.
46+
47+
Include the environment value of `SUPPRESS_SUPPORT=1`.
48+
4349
# Can't install nodemon: permission issue
4450

4551
You may need to install nodemon using `sudo` (which isn't recommended, but I understand it's unavoidable in some environments). If the install fails with this appearing in the npm error log, then you need the following workaround.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
4040
"prepush": "npm run lint",
4141
"killall": "ps auxww | grep node | grep -v grep | awk '{ print $2 }' | xargs kill -9",
42-
"postinstall": "node -e \"console.log('\\u001b[32mLove nodemon? You can now support the project via the open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[96m\\u001b[1mhttps://opencollective.com/nodemon/donate\\u001b[0m\\n')\" || exit 0"
42+
"postinstall": "node bin/postinstall || exit 0"
4343
},
4444
"devDependencies": {
4545
"@commitlint/cli": "^3.1.3",

0 commit comments

Comments
 (0)