forked from rockybars/atom-shell-packager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
win32.js
71 lines (58 loc) · 2.47 KB
/
win32.js
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
'use strict'
const common = require('./common')
const debug = require('debug')('electron-packager')
const path = require('path')
const series = require('run-series')
function updateWineMissingException (err) {
if (err && err.code === 'ENOENT' && err.syscall === 'spawn wine') {
err.message = 'Could not find "wine" on your system.\n\n' +
'Wine is required to use the app-copyright, app-version, build-version, icon, and \n' +
'win32metadata parameters for Windows targets.\n\n' +
'Make sure that the "wine" executable is in your PATH.\n\n' +
'See https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms for details.'
}
return err
}
module.exports = {
createApp: function createApp (opts, templatePath, callback) {
common.initializeApp(opts, templatePath, path.join('resources', 'app'), function buildWinApp (err, tempPath) {
if (err) return callback(err)
let newExeName = `${common.sanitizeAppName(opts.name)}.exe`
var operations = [
function (cb) {
common.rename(tempPath, 'electron.exe', newExeName, cb)
}
]
let win32metadata = Object.assign({}, opts['version-string'], opts.win32metadata)
var rcOpts = {'version-string': win32metadata}
if (opts['build-version']) {
rcOpts['file-version'] = opts['build-version']
}
if (opts['app-version']) {
rcOpts['product-version'] = opts['app-version']
}
if (opts['app-copyright']) {
rcOpts['version-string'].LegalCopyright = opts['app-copyright']
}
if (opts.icon || opts.win32metadata || opts['version-string'] || opts['app-copyright'] || opts['app-version'] || opts['build-version']) {
operations.push(function (cb) {
common.normalizeExt(opts.icon, '.ico', function (err, icon) {
// Icon might be omitted or only exist in one OS's format, so skip it if normalizeExt reports an error
if (!err) {
rcOpts.icon = icon
}
debug(`Running rcedit with the options ${JSON.stringify(rcOpts)}`)
require('rcedit')(path.join(tempPath, newExeName), rcOpts, function (err) {
cb(updateWineMissingException(err))
})
})
})
}
series(operations, function (err) {
if (err) return callback(err)
common.moveApp(opts, tempPath, callback)
})
})
},
updateWineMissingException: updateWineMissingException
}