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.

edge.js 3.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 edge_paths_1 = require("edge-paths");
  8. const child_process_1 = require("child_process");
  9. const utils_1 = require("@wdio/utils");
  10. const utils_2 = require("../utils");
  11. const finder_1 = require("./finder");
  12. const newLineRegex = /\r?\n/;
  13. const EDGE_BINARY_NAMES = ['edge', 'msedge', 'microsoftedge'];
  14. const EDGE_REGEX = /((ms|microsoft))?edge/g;
  15. function darwin() {
  16. const suffixes = [
  17. '/Contents/MacOS/Microsoft Edge'
  18. ];
  19. const appName = 'Microsoft Edge';
  20. const defaultPath = `/Applications/${appName}.app${suffixes[0]}`;
  21. let installations;
  22. if (utils_1.canAccess(defaultPath)) {
  23. installations = [defaultPath];
  24. }
  25. else {
  26. const appPaths = finder_1.darwinGetAppPaths(appName);
  27. installations = finder_1.darwinGetInstallations(appPaths, suffixes);
  28. }
  29. const priorities = [
  30. { regex: new RegExp(`^${process.env.HOME}/Applications/.*Microsoft Edge.app`), weight: 50 },
  31. { regex: /^\/Applications\/.*Microsoft Edge.app/, weight: 100 },
  32. { regex: /^\/Volumes\/.*Microsoft Edge.app/, weight: -2 }
  33. ];
  34. const whichFinds = utils_2.findByWhich(EDGE_BINARY_NAMES, [{ regex: EDGE_REGEX, weight: 51 }]);
  35. const installFinds = utils_2.sort(installations, priorities);
  36. return [...installFinds, ...whichFinds];
  37. }
  38. function linux() {
  39. let installations = [];
  40. const desktopInstallationFolders = [
  41. path_1.default.join(require('os').homedir(), '.local/share/applications/'),
  42. '/usr/share/applications/',
  43. ];
  44. desktopInstallationFolders.forEach(folder => {
  45. installations = installations.concat(findEdgeExecutables(folder));
  46. });
  47. return utils_2.findByWhich(EDGE_BINARY_NAMES, [{ regex: EDGE_REGEX, weight: 51 }]);
  48. }
  49. function win32() {
  50. const installations = [];
  51. const suffixes = [
  52. `${path_1.default.sep}Microsoft${path_1.default.sep}Edge${path_1.default.sep}Application${path_1.default.sep}edge.exe`,
  53. `${path_1.default.sep}Microsoft${path_1.default.sep}Edge${path_1.default.sep}Application${path_1.default.sep}msedge.exe`,
  54. `${path_1.default.sep}Microsoft${path_1.default.sep}Edge Dev${path_1.default.sep}Application${path_1.default.sep}msedge.exe`
  55. ];
  56. const prefixes = [
  57. process.env.LOCALAPPDATA || '', process.env.PROGRAMFILES || '', process.env['PROGRAMFILES(X86)'] || ''
  58. ].filter(Boolean);
  59. prefixes.forEach(prefix => suffixes.forEach(suffix => {
  60. const edgePath = path_1.default.join(prefix, suffix);
  61. if (utils_1.canAccess(edgePath)) {
  62. installations.push(edgePath);
  63. }
  64. }));
  65. if (installations.length === 0) {
  66. const edgePath = edge_paths_1.getEdgePath();
  67. if (utils_1.canAccess(edgePath)) {
  68. installations.push(edgePath);
  69. }
  70. }
  71. return installations;
  72. }
  73. function findEdgeExecutables(folder) {
  74. const argumentsRegex = /(^[^ ]+).*/;
  75. const edgeExecRegex = '^Exec=/.*/(edge)-.*';
  76. let installations = [];
  77. if (utils_1.canAccess(folder)) {
  78. let execPaths;
  79. try {
  80. execPaths = child_process_1.execSync(`grep -ER "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: 'pipe' });
  81. }
  82. catch (e) {
  83. execPaths = child_process_1.execSync(`grep -Er "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: 'pipe' });
  84. }
  85. execPaths = execPaths.toString().split(newLineRegex).map((execPath) => execPath.replace(argumentsRegex, '$1'));
  86. execPaths.forEach((execPath) => utils_1.canAccess(execPath) && installations.push(execPath));
  87. }
  88. return installations;
  89. }
  90. exports.default = {
  91. darwin,
  92. linux,
  93. win32
  94. };