errors.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. * node-sass: lib/errors.js
  3. */
  4. var sass = require('./extensions'),
  5. pkg = require('../package.json');
  6. function humanEnvironment() {
  7. return sass.getHumanEnvironment(sass.getBinaryName());
  8. }
  9. function foundBinaries() {
  10. return [
  11. 'Found bindings for the following environments:',
  12. foundBinariesList(),
  13. ].join('\n');
  14. }
  15. function foundBinariesList() {
  16. return sass.getInstalledBinaries().map(function(env) {
  17. return ' - ' + sass.getHumanEnvironment(env);
  18. }).join('\n');
  19. }
  20. function missingBinaryFooter() {
  21. return [
  22. 'This usually happens because your environment has changed since running `npm install`.',
  23. 'Run `npm rebuild node-sass` to download the binding for your current environment.',
  24. ].join('\n');
  25. }
  26. module.exports.unsupportedEnvironment = function() {
  27. return [
  28. 'Node Sass does not yet support your current environment: ' + humanEnvironment(),
  29. 'For more information on which environments are supported please see:',
  30. 'https://github.com/sass/node-sass/releases/tag/v' + pkg.version
  31. ].join('\n');
  32. };
  33. module.exports.missingBinary = function() {
  34. return [
  35. 'Missing binding ' + sass.getBinaryPath(),
  36. 'Node Sass could not find a binding for your current environment: ' + humanEnvironment(),
  37. '',
  38. foundBinaries(),
  39. '',
  40. missingBinaryFooter(),
  41. ].join('\n');
  42. };