postinstall.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env node
  2. function main() {
  3. if (process.env.SUPPRESS_SUPPORT || process.env.OPENCOLLECTIVE_HIDE || process.env.CI) {
  4. return;
  5. }
  6. try {
  7. const Configstore = require('configstore');
  8. const pkg = require(__dirname + '/../package.json');
  9. const now = Date.now();
  10. var week = 1000 * 60 * 60 * 24 * 7;
  11. // create a Configstore instance with an unique ID e.g.
  12. // Package name and optionally some default values
  13. const conf = new Configstore(pkg.name);
  14. const last = conf.get('lastCheck');
  15. if (!last || now - week > last) {
  16. 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');
  17. conf.set('lastCheck', now);
  18. }
  19. } catch (e) {
  20. 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');
  21. }
  22. }
  23. main();