postinstall.js 894 B

12345678910111213141516171819202122232425262728293031
  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. const message = '\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';
  7. try {
  8. const Configstore = require('configstore');
  9. const pkg = require(__dirname + '/../package.json');
  10. const now = Date.now();
  11. var week = 1000 * 60 * 60 * 24 * 7;
  12. // create a Configstore instance with an unique ID e.g.
  13. // Package name and optionally some default values
  14. const conf = new Configstore(pkg.name);
  15. const last = conf.get('lastCheck');
  16. if (!last || now - week > last) {
  17. console.log(message);
  18. conf.set('lastCheck', now);
  19. }
  20. } catch (e) {
  21. console.log(message);
  22. }
  23. }
  24. main();