forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathpackage-electron-builder.ts
More file actions
75 lines (60 loc) · 1.68 KB
/
Copy pathpackage-electron-builder.ts
File metadata and controls
75 lines (60 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* eslint-disable no-sync */
import * as path from 'path'
import * as cp from 'child_process'
import { promisify } from 'util'
import glob = require('glob')
const globPromise = promisify(glob)
import {
getArchitectureForFileName,
getDistPath,
getDistRoot,
} from './dist-info'
import { rename } from 'fs/promises'
import { getVersion } from '../app/package-info'
function getArchitecture() {
const arch = process.env.npm_config_arch || process.arch
switch (arch) {
case 'arm64':
return '--arm64'
default:
return '--x64'
}
}
export async function packageElectronBuilder(): Promise<string> {
const distPath = getDistPath()
const distRoot = getDistRoot()
const electronBuilder = path.resolve(
__dirname,
'..',
'node_modules',
'.bin',
'electron-builder'
)
const configPath = path.resolve(__dirname, 'electron-builder-linux.yml')
const args = [
'build',
'--prepackaged',
distPath,
getArchitecture(),
'--config',
configPath,
]
const { error } = cp.spawnSync(electronBuilder, args, { stdio: 'inherit' })
if (error != null) {
return Promise.reject(error)
}
const appImageInstaller = `${distRoot}/GitHubDesktopPlus-linux-*.AppImage`
const files = await globPromise(appImageInstaller)
if (files.length !== 1) {
return Promise.reject(
`Expected one AppImage installer but instead found '${files.join(
', '
)}' - exiting...`
)
}
const oldPath = files[0]
const newFileName = `GitHubDesktopPlus-v${getVersion()}-linux-${getArchitectureForFileName()}.AppImage`
const newPath = path.join(distRoot, newFileName)
await rename(oldPath, newPath)
return Promise.resolve(newPath)
}