Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. 'use strict';
  2. const supportsColor = require('supports-color');
  3. const hasFlag = require('has-flag');
  4. function parseVersion(versionString) {
  5. if (/^\d{3,4}$/.test(versionString)) {
  6. // Env var doesn't always use dots. example: 4601 => 46.1.0
  7. const m = /(\d{1,2})(\d{2})/.exec(versionString);
  8. return {
  9. major: 0,
  10. minor: parseInt(m[1], 10),
  11. patch: parseInt(m[2], 10)
  12. };
  13. }
  14. const versions = (versionString || '').split('.').map(n => parseInt(n, 10));
  15. return {
  16. major: versions[0],
  17. minor: versions[1],
  18. patch: versions[2]
  19. };
  20. }
  21. function supportsHyperlink(stream) {
  22. const {env} = process;
  23. if ('FORCE_HYPERLINK' in env) {
  24. return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
  25. }
  26. if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
  27. return false;
  28. }
  29. if (hasFlag('hyperlink=true') || hasFlag('hyperlink=always')) {
  30. return true;
  31. }
  32. // If they specify no colors, they probably don't want hyperlinks.
  33. if (!supportsColor.supportsColor(stream)) {
  34. return false;
  35. }
  36. if (stream && !stream.isTTY) {
  37. return false;
  38. }
  39. if (process.platform === 'win32') {
  40. return false;
  41. }
  42. if ('NETLIFY' in env) {
  43. return true;
  44. }
  45. if ('CI' in env) {
  46. return false;
  47. }
  48. if ('TEAMCITY_VERSION' in env) {
  49. return false;
  50. }
  51. if ('TERM_PROGRAM' in env) {
  52. const version = parseVersion(env.TERM_PROGRAM_VERSION);
  53. switch (env.TERM_PROGRAM) {
  54. case 'iTerm.app':
  55. if (version.major === 3) {
  56. return version.minor >= 1;
  57. }
  58. return version.major > 3;
  59. // No default
  60. }
  61. }
  62. if ('VTE_VERSION' in env) {
  63. // 0.50.0 was supposed to support hyperlinks, but throws a segfault
  64. if (env.VTE_VERSION === '0.50.0') {
  65. return false;
  66. }
  67. const version = parseVersion(env.VTE_VERSION);
  68. return version.major > 0 || version.minor >= 50;
  69. }
  70. return false;
  71. }
  72. module.exports = {
  73. supportsHyperlink,
  74. stdout: supportsHyperlink(process.stdout),
  75. stderr: supportsHyperlink(process.stderr)
  76. };