Skip to content

Commit

Permalink
Merge pull request #950 from DustinCampbell/fix-os-arch-on-windows
Browse files Browse the repository at this point in the history
Account for the fact that 'wmic os get osarchitecture' returns localized information
  • Loading branch information
DustinCampbell authored Nov 15, 2016
2 parents aa88053 + 5f5e93c commit 8011a08
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ gulp.task('package:offline', ['clean'], () => {
var packageName = name + '.' + version;

var packages = [];
packages.push(new PlatformInformation('win32', '64-bit'));
packages.push(new PlatformInformation('win32', 'x86_64'));
packages.push(new PlatformInformation('darwin', 'x86_64'));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('centos', '7')));
packages.push(new PlatformInformation('linux', 'x86_64', new LinuxDistribution('debian', '8')));
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@
"win32"
],
"architectures": [
"x86",
"32-bit"
"x86"
]
},
{
Expand All @@ -123,8 +122,7 @@
"win32"
],
"architectures": [
"x86_64",
"64-bit"
"x86_64"
]
},
{
Expand Down
14 changes: 11 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ export class PlatformInformation {
if (architecture) {
let archArray: string[] = architecture.split(os.EOL);
if (archArray.length >= 2) {
return archArray[1].trim();
let arch = archArray[1].trim();

// Note: This string can be localized. So, we'll just check to see if it contains 32 or 64.
if (arch.indexOf('64') >= 0) {
return "x86_64";
}
else if (arch.indexOf('32') >= 0) {
return "x86";
}
}
}

Expand Down Expand Up @@ -204,8 +212,8 @@ export class PlatformInformation {
switch (platform) {
case 'win32':
switch (architecture) {
case '32-bit': return 'win7-x86';
case '64-bit': return 'win7-x64';
case 'x86': return 'win7-x86';
case 'x86_64': return 'win7-x64';
}

throw new Error(`Unsupported Windows architecture: ${architecture}`);
Expand Down
4 changes: 2 additions & 2 deletions test/platform.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ suite("Platform", () => {
});

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

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

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

platformInfo.runtimeId.should.equal('win7-x64');
})
Expand Down

0 comments on commit 8011a08

Please sign in to comment.