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.

firefox.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const path_1 = __importDefault(require("path"));
  7. const child_process_1 = require("child_process");
  8. const utils_1 = require("@wdio/utils");
  9. const utils_2 = require("../utils");
  10. const finder_1 = require("./finder");
  11. const newLineRegex = /\r?\n/;
  12. function darwin() {
  13. const suffixes = [
  14. '/Contents/MacOS/firefox-bin'
  15. ];
  16. const appName = 'Firefox Nightly';
  17. const defaultPath = `/Applications/${appName}.app${suffixes[0]}`;
  18. let installations;
  19. if (utils_1.canAccess(defaultPath)) {
  20. installations = [defaultPath];
  21. }
  22. else {
  23. const appPaths = finder_1.darwinGetAppPaths(appName);
  24. installations = finder_1.darwinGetInstallations(appPaths, suffixes);
  25. }
  26. const priorities = [
  27. { regex: new RegExp(`^${process.env.HOME}/Applications/.*Firefox.app`), weight: 50 },
  28. { regex: /^\/Applications\/.*Firefox.app/, weight: 100 },
  29. { regex: /^\/Volumes\/.*Firefox.app/, weight: -2 }
  30. ];
  31. const whichFinds = utils_2.findByWhich(['firefox-nightly', 'firefox-trunk'], [{ regex: /firefox-nightly/, weight: 51 }]);
  32. const installFinds = utils_2.sort(installations, priorities);
  33. return [...installFinds, ...whichFinds];
  34. }
  35. function linux() {
  36. let installations = [];
  37. const desktopInstallationFolders = [
  38. path_1.default.join(require('os').homedir(), '.local/share/applications/'),
  39. '/usr/share/applications/',
  40. ];
  41. desktopInstallationFolders.forEach(folder => {
  42. installations = installations.concat(findFirefoxExecutables(folder));
  43. });
  44. const whichFinds = utils_2.findByWhich(['firefox-nightly', 'firefox-trunk', 'firefox'], [{ regex: /firefox/, weight: 51 }]);
  45. return [...installations, ...whichFinds];
  46. }
  47. function win32() {
  48. const installations = [];
  49. const suffixes = [
  50. `${path_1.default.sep}Firefox Nightly${path_1.default.sep}Application${path_1.default.sep}firefox.exe`
  51. ];
  52. const prefixes = [
  53. process.env.LOCALAPPDATA || '', process.env.PROGRAMFILES || '', process.env['PROGRAMFILES(X86)'] || ''
  54. ].filter(Boolean);
  55. prefixes.forEach(prefix => suffixes.forEach(suffix => {
  56. const firefoxPath = path_1.default.join(prefix, suffix);
  57. if (utils_1.canAccess(firefoxPath)) {
  58. installations.push(firefoxPath);
  59. }
  60. }));
  61. return installations;
  62. }
  63. function findFirefoxExecutables(folder) {
  64. const argumentsRegex = /(^[^ ]+).*/;
  65. const edgeExecRegex = '^Exec=/.*/(firefox)-.*';
  66. let installations = [];
  67. if (utils_1.canAccess(folder)) {
  68. let execPaths;
  69. try {
  70. execPaths = child_process_1.execSync(`grep -ER "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: 'pipe' });
  71. }
  72. catch (e) {
  73. execPaths = child_process_1.execSync(`grep -Er "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: 'pipe' });
  74. }
  75. execPaths = execPaths.toString().split(newLineRegex).map((execPath) => execPath.replace(argumentsRegex, '$1'));
  76. execPaths.forEach((execPath) => utils_1.canAccess(execPath) && installations.push(execPath));
  77. }
  78. return installations;
  79. }
  80. exports.default = {
  81. darwin,
  82. linux,
  83. win32
  84. };