Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support env.SUPPRESS_SUPPORT #1334

Merged
merged 3 commits into from
May 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node

function main() {
if (process.env.SUPPRESS_SUPPORT) {
return;
}

try {
const Configstore = require('configstore');
const pkg = require(__dirname + '/../package.json');
const now = Date.now();

var week = 1000 * 60 * 60 * 24 * 7;

// create a Configstore instance with an unique ID e.g.
// Package name and optionally some default values
const conf = new Configstore(pkg.name);
const last = conf.get('lastCheck');

if (!last || now - week > last) {
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');
conf.set('lastCheck', now);
}
} catch (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');
}
}

main();
6 changes: 6 additions & 0 deletions faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ For example, mocha@3.x will exit with `2` on failing tests. To handle the exit c
nodemon -x 'mocha test/bad.test.js || exit 1'
```

# You want to suppress the request for support message

Perhaps you're [already supporting nodemon](https://opencollective.com/nodemon) or you're using it in CI and it needs to be quietened.

Include the environment value of `SUPPRESS_SUPPORT=1`.

# Can't install nodemon: permission issue

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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"prepush": "npm run lint",
"killall": "ps auxww | grep node | grep -v grep | awk '{ print $2 }' | xargs kill -9",
"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"
"postinstall": "node bin/postinstall || exit 0"
},
"devDependencies": {
"@commitlint/cli": "^3.1.3",
Expand Down