-
-
Notifications
You must be signed in to change notification settings - Fork 315
/
Copy pathafterPack.ts
34 lines (28 loc) · 847 Bytes
/
afterPack.ts
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
import * as fs from 'fs-extra'
import { chdir } from 'process'
import { exec } from './util'
interface Target {
name: 'appImage' | string
}
interface Context {
appOutDir: string // .../build/clean/build/linux-unpacked
outDir: string // .../build/clean/build
targets: [Target]
}
export default async function (context: Context) {
console.log(context)
const isLinux = context.targets.find(target => target.name === 'appImage')
if (!isLinux) {
return
}
const originalDir = process.cwd()
const dirname = context.appOutDir
chdir(dirname)
await exec('mv', ['mqtt-explorer', 'mqtt-explorer.bin'])
const wrapperScript = `#!/bin/bash
"\${BASH_SOURCE%/*}"/mqtt-explorer.bin "$@" --no-sandbox
`
fs.writeFileSync('mqtt-explorer', wrapperScript)
await exec('chmod', ['+x', 'mqtt-explorer'])
chdir(originalDir)
}