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
var path = require('path')
var spawn = require('child_process').spawn
var pairSettings = ['version-string']
var singleSettings = ['file-version', 'product-version', 'icon', 'requested-execution-level']
var noPrefixSettings = ['application-manifest']
module.exports = function (exe, options, callback) {
var rcedit = path.resolve(__dirname, '..', 'bin', 'rcedit.exe')
var args = [exe]
pairSettings.forEach(function (name) {
if (options[name] != null) {
for (var key in options[name]) {
var value = options[name][key]
args.push('--set-' + name)
args.push(key)
args.push(value)
}
}
})
singleSettings.forEach(function (name) {
if (options[name] != null) {
args.push('--set-' + name)
args.push(options[name])
}
})
noPrefixSettings.forEach(function (name) {
if (options[name] != null) {
args.push('--' + name)
args.push(options[name])
}
})
var spawnOptions = {}
spawnOptions.env = Object.create(process.env)
if (process.platform !== 'win32') {
args.unshift(rcedit)
rcedit = 'wine'
// Supress fixme: stderr log messages
spawnOptions.env.WINEDEBUG = '-all'
}
var child = spawn(rcedit, args, spawnOptions)
var stderr = ''
var error = null
child.on('error', function (err) {
if (error == null) error = err
})
child.stderr.on('data', function (data) {
stderr += data
})
child.on('close', function (code) {
if (error != null) {
callback(error)
} else if (code === 0) {
callback()
} else {
var message = 'rcedit.exe failed with exit code ' + code
stderr = stderr.trim()
if (stderr) message += '. ' + stderr
callback(new Error(message))
}
})
}