info.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * grunt-cli
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2016 Tyler Kellen, contributors
  6. * Licensed under the MIT license.
  7. * https://github.com/gruntjs/grunt-init/blob/master/LICENSE-MIT
  8. */
  9. 'use strict';
  10. // Project metadata.
  11. var pkg = require('../package.json');
  12. // Display grunt-cli version.
  13. exports.version = function() {
  14. console.log('grunt-cli v' + pkg.version);
  15. };
  16. // Show help, then exit with a message and error code.
  17. exports.fatal = function(msg, code) {
  18. exports.helpHeader();
  19. console.log('Fatal error: ' + msg);
  20. console.log('');
  21. exports.helpFooter();
  22. process.exit(code);
  23. };
  24. // Show help and exit.
  25. exports.help = function() {
  26. exports.helpHeader();
  27. exports.helpFooter();
  28. process.exit();
  29. };
  30. // Help header.
  31. exports.helpHeader = function() {
  32. console.log('grunt-cli: ' + pkg.description + ' (v' + pkg.version + ')');
  33. console.log('');
  34. };
  35. // Help footer.
  36. exports.helpFooter = function() {
  37. [
  38. 'If you\'re seeing this message, grunt hasn\'t been installed locally to',
  39. 'your project. For more information about installing and configuring grunt,',
  40. 'please see the Getting Started guide:',
  41. '',
  42. 'https://gruntjs.com/getting-started',
  43. ].forEach(function(str) { console.log(str); });
  44. };