forked from electron-userland/electron-prebuilt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
executable file
·43 lines (34 loc) · 1.29 KB
/
Copy pathinstall.js
File metadata and controls
executable file
·43 lines (34 loc) · 1.29 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
#!/usr/bin/env node
// maintainer note - x.y.z-ab version in package.json -> x.y.z
var version = require('./package').version.replace(/-.*/, '')
var fs = require('fs')
var os = require('os')
var path = require('path')
var extract = require('extract-zip')
var download = require('electron-download')
var arch = 'x64'
var platform = os.platform()
function onerror (err) {
throw err
}
var paths = {
darwin: path.join(__dirname, './dist/Electron.app/Contents/MacOS/Electron'),
// linux: path.join(__dirname, './dist/electron'), // Unity WebPlayer not supported
win32: path.join(__dirname, './dist/electron.exe')
}
if (!paths[platform]) throw new Error('Unknown platform: ' + platform)
// while 64 bit Unity WebPlayer exists on Windows, it is not as
// stable and has a constant watermark in the bottom right corner
if (platform == 'win32') arch = 'ia32';
// downloads if not cached
download({version: version, arch: arch}, extractFile)
// unzips and makes path.txt point at the correct executable
function extractFile (err, zipPath) {
if (err) return onerror(err)
fs.writeFile(path.join(__dirname, 'path.txt'), paths[platform], function (err) {
if (err) return onerror(err)
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
if (err) return onerror(err)
})
})
}