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 |
|
36 |
|
37 | function uname() {
|
38 | return childProcess
|
39 | .execSync('uname -m')
|
40 | .toString()
|
41 | .trim();
|
42 | }
|
43 | exports.uname = uname;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function getNodeArch(arch) {
|
49 | if (arch === 'arm') {
|
50 |
|
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 |
|
64 |
|
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 |
|
\ | No newline at end of file |