xmas.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // happy xmas
  2. var log = require('npmlog')
  3. module.exports = function (args, cb) {
  4. var s = process.platform === 'win32' ? ' *' : ' \u2605'
  5. var f = '\uFF0F'
  6. var b = '\uFF3C'
  7. var x = process.platform === 'win32' ? ' ' : ''
  8. var o = [
  9. '\u0069', '\u0020', '\u0020', '\u0020', '\u0020', '\u0020',
  10. '\u0020', '\u0020', '\u0020', '\u0020', '\u0020', '\u0020',
  11. '\u0020', '\u2E1B', '\u2042', '\u2E2E', '&', '@', '\uFF61'
  12. ]
  13. var oc = [33, 34, 35, 36, 37]
  14. var l = '\u005e'
  15. function w (s) { process.stderr.write(s) }
  16. w('\n')
  17. ;(function T (H) {
  18. for (var i = 0; i < H; i++) w(' ')
  19. w(x + '\u001b[33m' + s + '\n')
  20. var M = H * 2 - 1
  21. for (var L = 1; L <= H; L++) {
  22. var O = L * 2 - 2
  23. var S = (M - O) / 2
  24. for (i = 0; i < S; i++) w(' ')
  25. w(x + '\u001b[21m')
  26. w(x + '\u001b[32m' + f)
  27. for (i = 0; i < O; i++) {
  28. w(
  29. '\u001b[' + oc[Math.floor(Math.random() * oc.length)] + 'm' +
  30. o[Math.floor(Math.random() * o.length)]
  31. )
  32. }
  33. w(x + '\u001b[32m' + b + '\n')
  34. w(x + '\u001b[0m')
  35. }
  36. w(' ')
  37. for (i = 1; i < H; i++) w('\u001b[32m' + l)
  38. w('| ' + x + ' |')
  39. for (i = 1; i < H; i++) w('\u001b[32m' + l)
  40. if (H > 10) {
  41. w('\n ')
  42. for (i = 1; i < H; i++) w(' ')
  43. w('| ' + x + ' |')
  44. for (i = 1; i < H; i++) w(' ')
  45. }
  46. })(20)
  47. w('\n\n')
  48. log.heading = ''
  49. log.addLevel('npm', 100000, log.headingStyle)
  50. log.npm('loves you', 'Happy Xmas, JavaScripters!')
  51. cb()
  52. }
  53. var dg = false
  54. Object.defineProperty(module.exports, 'usage', {get: function () {
  55. if (dg) module.exports([], function () {})
  56. dg = true
  57. return ' '
  58. }})