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.

utils.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const childProcess = require("child_process");
  4. const fs = require("fs-extra");
  5. const os = require("os");
  6. const path = require("path");
  7. async function useAndRemoveDirectory(directory, fn) {
  8. let result;
  9. try {
  10. result = await fn(directory);
  11. }
  12. finally {
  13. await fs.remove(directory);
  14. }
  15. return result;
  16. }
  17. async function withTempDirectoryIn(parentDirectory = os.tmpdir(), fn) {
  18. const tempDirectoryPrefix = 'electron-download-';
  19. const tempDirectory = await fs.mkdtemp(path.resolve(parentDirectory, tempDirectoryPrefix));
  20. return useAndRemoveDirectory(tempDirectory, fn);
  21. }
  22. exports.withTempDirectoryIn = withTempDirectoryIn;
  23. async function withTempDirectory(fn) {
  24. return withTempDirectoryIn(undefined, fn);
  25. }
  26. exports.withTempDirectory = withTempDirectory;
  27. function normalizeVersion(version) {
  28. if (!version.startsWith('v')) {
  29. return `v${version}`;
  30. }
  31. return version;
  32. }
  33. exports.normalizeVersion = normalizeVersion;
  34. /**
  35. * Runs the `uname` command and returns the trimmed output.
  36. */
  37. function uname() {
  38. return childProcess
  39. .execSync('uname -m')
  40. .toString()
  41. .trim();
  42. }
  43. exports.uname = uname;
  44. /**
  45. * Generates an architecture name that would be used in an Electron or Node.js
  46. * download file name.
  47. */
  48. function getNodeArch(arch) {
  49. if (arch === 'arm') {
  50. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  51. switch (process.config.variables.arm_version) {
  52. case '6':
  53. return uname();
  54. case '7':
  55. default:
  56. return 'armv7l';
  57. }
  58. }
  59. return arch;
  60. }
  61. exports.getNodeArch = getNodeArch;
  62. /**
  63. * Generates an architecture name that would be used in an Electron or Node.js
  64. * download file name, from the `process` module information.
  65. */
  66. function getHostArch() {
  67. return getNodeArch(process.arch);
  68. }
  69. exports.getHostArch = getHostArch;
  70. function ensureIsTruthyString(obj, key) {
  71. if (!obj[key] || typeof obj[key] !== 'string') {
  72. throw new Error(`Expected property "${key}" to be provided as a string but it was not`);
  73. }
  74. }
  75. exports.ensureIsTruthyString = ensureIsTruthyString;
  76. function isOfficialLinuxIA32Download(platform, arch, version, mirrorOptions) {
  77. return (platform === 'linux' &&
  78. arch === 'ia32' &&
  79. Number(version.slice(1).split('.')[0]) >= 4 &&
  80. typeof mirrorOptions === 'undefined');
  81. }
  82. exports.isOfficialLinuxIA32Download = isOfficialLinuxIA32Download;
  83. //# sourceMappingURL=utils.js.map