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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. exports.getAnyEdgeStable = exports.getAnyEdgeLatest = exports.getEdgeCanaryPath = exports.getEdgeBetaPath = exports.getEdgeDevPath = exports.getEdgePath = void 0;
  7. const fs_1 = __importDefault(require("fs"));
  8. const path_1 = __importDefault(require("path"));
  9. const which_1 = __importDefault(require("which"));
  10. let platform = process.platform;
  11. function getEdgeLinux(binaryNames) {
  12. if (process.platform !== "linux") {
  13. return null;
  14. }
  15. if (!Array.isArray(binaryNames)) {
  16. binaryNames = [binaryNames];
  17. }
  18. let paths = [];
  19. for (let name of binaryNames) {
  20. try {
  21. let path = which_1.default.sync(name);
  22. return path;
  23. }
  24. catch (e) {
  25. paths.push(name);
  26. }
  27. }
  28. throw {
  29. package: "edge-paths",
  30. message: "Edge browser not found. Please recheck your installation. \
  31. Here are list of executable we tried to search",
  32. paths,
  33. };
  34. }
  35. function getEdgeExe(edgeDirName) {
  36. if (process.platform !== "win32") {
  37. return null;
  38. }
  39. let paths = [];
  40. let suffix = `\\Microsoft\\${edgeDirName}\\Application\\msedge.exe`;
  41. let prefixes = [process.env.LOCALAPPDATA, process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"]].filter((v) => !!v);
  42. for (let prefix of prefixes) {
  43. let edgePath = path_1.default.join(prefix, suffix);
  44. paths.push(edgePath);
  45. if (fs_1.default.existsSync(edgePath)) {
  46. return edgePath;
  47. }
  48. }
  49. throw {
  50. package: "edge-paths",
  51. message: "Edge browser not found. Please recheck your installation.",
  52. paths,
  53. };
  54. }
  55. function getEdgeDarwin(defaultPath) {
  56. if (process.platform !== "darwin") {
  57. return null;
  58. }
  59. if (fs_1.default.existsSync(defaultPath)) {
  60. return defaultPath;
  61. }
  62. throw {
  63. package: "edge-paths",
  64. message: `Edge browser not found. Please recheck your installation. Path ${defaultPath}`,
  65. path: defaultPath,
  66. };
  67. }
  68. function getEdgePath() {
  69. let edge = {
  70. linux: getEdgeLinux(["edge"]),
  71. darwin: getEdgeDarwin("/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"),
  72. win32: getEdgeExe("Edge"),
  73. };
  74. if (platform && platform in edge) {
  75. return edge[platform];
  76. }
  77. throwInvalidPlatformError();
  78. }
  79. exports.getEdgePath = getEdgePath;
  80. function getEdgeDevPath() {
  81. let edgeDev = {
  82. linux: getEdgeLinux("microsoft-edge-dev"),
  83. darwin: getEdgeDarwin("/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev"),
  84. win32: getEdgeExe("Edge Dev"),
  85. };
  86. if (platform && platform in edgeDev) {
  87. return edgeDev[platform];
  88. }
  89. throwInvalidPlatformError();
  90. }
  91. exports.getEdgeDevPath = getEdgeDevPath;
  92. function getEdgeBetaPath() {
  93. let edgeBeta = {
  94. darwin: getEdgeDarwin("/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta"),
  95. win32: getEdgeExe("Edge Beta"),
  96. };
  97. if (platform && platform in edgeBeta) {
  98. return edgeBeta[platform];
  99. }
  100. throwInvalidPlatformError();
  101. }
  102. exports.getEdgeBetaPath = getEdgeBetaPath;
  103. function getEdgeCanaryPath() {
  104. let edgeCanary = {
  105. darwin: getEdgeDarwin("/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary"),
  106. win32: getEdgeExe("Edge SxS"),
  107. };
  108. if (platform && platform in edgeCanary) {
  109. return edgeCanary[platform];
  110. }
  111. throwInvalidPlatformError();
  112. }
  113. exports.getEdgeCanaryPath = getEdgeCanaryPath;
  114. function getAnyEdgeLatest() {
  115. try {
  116. return getEdgeCanaryPath();
  117. }
  118. catch (e) { }
  119. try {
  120. return getEdgeDevPath();
  121. }
  122. catch (e) { }
  123. try {
  124. return getEdgeBetaPath();
  125. }
  126. catch (e) { }
  127. try {
  128. return getEdgeDevPath();
  129. }
  130. catch (e) { }
  131. throw {
  132. package: "edge-paths",
  133. message: `Unable to find any path`,
  134. };
  135. }
  136. exports.getAnyEdgeLatest = getAnyEdgeLatest;
  137. function getAnyEdgeStable() {
  138. try {
  139. }
  140. catch (e) {
  141. return getEdgePath();
  142. }
  143. try {
  144. return getEdgeBetaPath();
  145. }
  146. catch (e) { }
  147. try {
  148. return getEdgeDevPath();
  149. }
  150. catch (e) { }
  151. try {
  152. return getEdgeCanaryPath();
  153. }
  154. catch (e) { }
  155. throw {
  156. package: "edge-paths",
  157. message: `Unable to find any path`,
  158. };
  159. }
  160. exports.getAnyEdgeStable = getAnyEdgeStable;
  161. function throwInvalidPlatformError() {
  162. throw {
  163. package: "edge-paths",
  164. message: "Your platform is not supported. Only mac and windows are supported currently",
  165. };
  166. }
  167. if (require.main === module) {
  168. function findEdge(func) {
  169. try {
  170. let path = func();
  171. console.log("Found path", path);
  172. }
  173. catch (e) {
  174. console.log("Error on finding path", e);
  175. }
  176. }
  177. findEdge(() => getEdgeBetaPath());
  178. findEdge(() => getEdgeCanaryPath());
  179. findEdge(() => getEdgeDevPath());
  180. findEdge(() => getEdgePath());
  181. }