Skip to content

Commit 8011a08

Browse files
Merge pull request #950 from DustinCampbell/fix-os-arch-on-windows
Account for the fact that 'wmic os get osarchitecture' returns localized information
2 parents aa88053 + 5f5e93c commit 8011a08

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ gulp.task('package:offline', ['clean'], () => {
118118
var packageName = name + '.' + version;
119119

120120
var packages = [];
121-
packages.push(new PlatformInformation('win32', '64-bit'));
121+
packages.push(new PlatformInformation('win32', 'x86_64'));
122122
packages.push(new PlatformInformation('darwin', 'x86_64'));
123123
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('centos', '7')));
124124
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('debian', '8')));

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@
111111
"win32"
112112
],
113113
"architectures": [
114-
"x86",
115-
"32-bit"
114+
"x86"
116115
]
117116
},
118117
{
@@ -123,8 +122,7 @@
123122
"win32"
124123
],
125124
"architectures": [
126-
"x86_64",
127-
"64-bit"
125+
"x86_64"
128126
]
129127
},
130128
{

src/platform.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,15 @@ export class PlatformInformation {
172172
if (architecture) {
173173
let archArray: string[] = architecture.split(os.EOL);
174174
if (archArray.length >= 2) {
175-
return archArray[1].trim();
175+
let arch = archArray[1].trim();
176+
177+
// Note: This string can be localized. So, we'll just check to see if it contains 32 or 64.
178+
if (arch.indexOf('64') >= 0) {
179+
return "x86_64";
180+
}
181+
else if (arch.indexOf('32') >= 0) {
182+
return "x86";
183+
}
176184
}
177185
}
178186

@@ -204,8 +212,8 @@ export class PlatformInformation {
204212
switch (platform) {
205213
case 'win32':
206214
switch (architecture) {
207-
case '32-bit': return 'win7-x86';
208-
case '64-bit': return 'win7-x64';
215+
case 'x86': return 'win7-x86';
216+
case 'x86_64': return 'win7-x64';
209217
}
210218

211219
throw new Error(`Unsupported Windows architecture: ${architecture}`);

test/platform.tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ suite("Platform", () => {
3838
});
3939

4040
test("Compute correct RID for Windows 32-bit", () => {
41-
const platformInfo = new PlatformInformation('win32', '32-bit');
41+
const platformInfo = new PlatformInformation('win32', 'x86');
4242

4343
platformInfo.runtimeId.should.equal('win7-x86');
4444
})
4545

4646
test("Compute correct RID for Windows 64-bit", () => {
47-
const platformInfo = new PlatformInformation('win32', '64-bit');
47+
const platformInfo = new PlatformInformation('win32', 'x86_64');
4848

4949
platformInfo.runtimeId.should.equal('win7-x64');
5050
})

0 commit comments

Comments
 (0)