Skip to content

Commit a3e0d69

Browse files
Merge pull request #78 from colonelpopcorn/issue71
Fix OS callback
2 parents 2a5b4a5 + d92e6f8 commit a3e0d69

File tree

7 files changed

+4949
-250
lines changed

7 files changed

+4949
-250
lines changed

.jshintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
"predef" : [ // Extra globals.
2222
"require",
2323
"define",
24-
"notify"
24+
"notify",
25+
"expect",
26+
"it",
27+
"afterEach",
28+
"describe",
29+
"jest"
2530
],
2631

2732

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ node_js:
77
- "12"
88
- "11"
99
- "10"
10-
before_install:
11-
- npm install -g jshint
10+
before_install:
11+
- npm install -g jshint jest
1212
install:
1313
- npm install
1414
script:
1515
- npm test
16+
- npm run lint

lib/virtualbox.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
// @todo use a promise library instead of so many callbacks
44

5-
var execFile = require('child_process').execFile,
5+
const execFile = require('child_process').execFile,
66
host_platform = process.platform,
77
logging = require('./logging'),
8-
vBoxManageBinary,
9-
vbox_version,
10-
known_OS_types = {
8+
known_OS_types = {
119
WINDOWS: 'windows',
1210
MAC: 'mac',
1311
LINUX: 'linux'
14-
},
15-
allowedBinaries = ["VBoxControl", vBoxManageBinary];
16-
12+
};
1713

14+
let vBoxManageBinary,
15+
vbox_version;
16+
1817

1918
// Host operating system
2019
if (/^win/.test(host_platform)) {
@@ -35,6 +34,10 @@ if (/^win/.test(host_platform)) {
3534

3635
}
3736

37+
const
38+
allowedBinaries = ["VBoxControl", vBoxManageBinary];
39+
40+
3841
execFile(vBoxManageBinary, ["--version"], function(error, stdout, stderr) {
3942
// e.g., "4.3.38r106717" or "5.0.20r106931"
4043
vbox_version = stdout.split(".")[0];
@@ -429,7 +432,7 @@ var guestproperty = {
429432
// The ostype is matched against the ID attribute of 'vboxmanage list ostypes'
430433
if (stdout.indexOf('ostype="Windows') !== -1) {
431434
guestproperty.os_type = known_OS_types.WINDOWS;
432-
} else if (stdout.indexOf('ostype="MacOS') !== -1) {
435+
} else if (['ostype="MacOS', 'ostype="Mac OS machine'].includes(stdout)) {
433436
guestproperty.os_type = known_OS_types.MAC;
434437
} else {
435438
guestproperty.os_type = known_OS_types.LINUX;
@@ -443,8 +446,9 @@ var guestproperty = {
443446
}
444447

445448
try {
446-
vboxmanage('showvminfo', '--machinereadable', vmname, getOSTypeCallback);
449+
vboxmanage(['showvminfo', '--machinereadable', vmname], getOSTypeCallback);
447450
} catch (e) {
451+
logging.error(e);
448452
logging.info('Could not showvminfo for %s', vmname);
449453
}
450454
}

0 commit comments

Comments
 (0)