Skip to content

Commit 8c0c8b4

Browse files
committed
add ability to specify target arch
1 parent 3e2d3c2 commit 8c0c8b4

5 files changed

Lines changed: 56 additions & 21 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var options = {
4747

4848
// optional
4949
description: "Some description",
50+
arch: 'x86',
5051
localInstall: true
5152

5253
}
@@ -75,6 +76,7 @@ Options:
7576
-n, --name
7677
-v, --version Specify application version
7778
-m, --manufacturer
79+
-a, --arch Specify the target architecture: x86 or x64 (optional)
7880
-u, --upgrade-code Specify GUID to use for upgrading from other versions
7981
-i, --icon Specify an icon to use on shortcuts and installer
8082
-e, --executable Specify file to create shortcuts for

cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ var opts = require("nomnom")
3535
required: true
3636
},
3737

38+
'arch': {
39+
abbr: 'a',
40+
help: 'Specify the target architecture: x86 or x64 (optional)'
41+
},
42+
3843
'upgradeCode': {
3944
abbr: 'u',
4045
full: 'upgrade-code',

generate-xml.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function installerFor (components, options) {
8181
Name: 'SourceDir'
8282
}, [
8383
el('Directory', {
84-
Id: options.localInstall ? 'LocalAppDataFolder' : 'ProgramFilesFolder',
84+
Id: getProgramsFolder(options),
8585
}, [
8686
el('Directory', {
8787
Id: 'INSTALLDIR',
@@ -168,6 +168,18 @@ function getComponents (path, options, cb) {
168168
})
169169
}
170170

171+
function getProgramsFolder (options) {
172+
if (options.localInstall) {
173+
return 'LocalAppDataFolder'
174+
} else {
175+
if (options.arch === 'x64') {
176+
return 'ProgramFiles64Folder'
177+
} else {
178+
return 'ProgramFilesFolder'
179+
}
180+
}
181+
}
182+
171183
function escapeId (id) {
172184
return encodeURIComponent(id)
173185
}

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ module.exports = function(options, cb) {
1111
// upgradeCode
1212
// version
1313
// manufacturer
14+
// arch
1415
// iconPath
1516
// executable
1617
// localInstall
1718

1819
writeXml(options, function (err, path) {
19-
execFile('wixl', [path, '-o', options.output], cb)
20+
var args = [path, '-o', options.output]
21+
22+
if (options.arch) {
23+
args.push('--arch', options.arch)
24+
}
25+
26+
execFile('wixl', args, cb)
2027
})
2128
}
2229

lib/hyperxml.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@ var Xml = require('xmlbuilder')
22

33
module.exports = h
44

5-
var proto = {}
5+
var proto = {
6+
constructor: h
7+
}
8+
69
Object.defineProperty(proto, 'toXml', {
710
value: function (options) {
8-
return Xml.create(this).end(options)
11+
12+
var root = Xml.create(this.name, this.attributes)
13+
addChildren.call(root, this.childNodes)
14+
15+
function addChildren(child) {
16+
var parent = this
17+
if (Array.isArray(child)) {
18+
child.forEach(addChildren, parent)
19+
} else if (typeof child === 'string') {
20+
parent.text(child)
21+
} else if (child instanceof Object) {
22+
if (child.name) {
23+
var node = parent.element(child.name, child.attributes)
24+
addChildren.call(node, child.childNodes)
25+
}
26+
}
27+
}
28+
29+
return root.toString(options)
930
},
1031
writable: true,
1132
configurable: true,
@@ -15,25 +36,13 @@ Object.defineProperty(proto, 'toXml', {
1536
function h (name, attr, children) {
1637
var obj = Object.create(proto)
1738

18-
obj[name] = []
19-
20-
if (Array.isArray(attr)) {
39+
if (Array.isArray(attr) && !children) {
2140
children = attr
22-
attr = null
23-
}
24-
25-
if (attr && Object.keys(attr).length) {
26-
var mappedAttributes = {}
27-
for (var k in attr) {
28-
mappedAttributes['@' + k] = attr[k]
29-
}
30-
obj[name].push(mappedAttributes)
31-
}
32-
33-
34-
if (children) {
35-
obj[name].push(children)
41+
attr = {}
3642
}
3743

44+
obj.name = name
45+
obj.attributes = attr
46+
obj.childNodes = children
3847
return obj
3948
}

0 commit comments

Comments
 (0)