Skip to content

Commit 57313a5

Browse files
Merge pull request #36 from Node-Virtualization/vbox5
Merge vbox5 branch for --execute
2 parents ee72998 + 6dbcc89 commit 57313a5

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

lib/virtualbox.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var exec = require('child_process').exec,
66
host_platform = process.platform,
77
logging = require('./logging'),
88
vBoxManageBinary,
9+
vbox_version,
910
known_OS_types = {
1011
WINDOWS: 'windows',
1112
MAC: 'mac',
@@ -32,6 +33,12 @@ if (/^win/.test(host_platform)) {
3233

3334
}
3435

36+
exec(vBoxManageBinary + ' --version', function(error, stdout, stderr) {
37+
// e.g., "4.3.38r106717" or "5.0.20r106931"
38+
vbox_version = stdout.split(".")[0];
39+
logging.info("Virtualbox version detected as %s", vbox_version);
40+
});
41+
3542
function command(cmd, callback) {
3643
exec(cmd, function(err, stdout, stderr) {
3744

@@ -274,17 +281,22 @@ function vmExec(options, callback) {
274281

275282
function getOSTypeCb(os_type) {
276283
var cmd = 'guestcontrol "' + vm + '"';
284+
var runcmd = ' execute --image ';
285+
286+
if (vbox_version == 5) {
287+
runcmd = ' run ';
288+
}
277289

278290
switch (os_type) {
279291
case known_OS_types.WINDOWS:
280292
path = path.replace(/\\/g, '\\\\');
281-
cmd += ' execute --image "cmd.exe" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
293+
cmd += runcmd + ' "cmd.exe" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
282294
break;
283295
case known_OS_types.MAC:
284-
cmd += ' execute --image "/usr/bin/open -a" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
296+
cmd += runcmd + ' "/usr/bin/open -a" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
285297
break;
286298
case known_OS_types.LINUX:
287-
cmd += ' execute --image "/bin/sh" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
299+
cmd += runcmd + ' "/bin/sh" --username ' + username + (password ? ' --password ' + password : '') + ' -- "/c" "' + path + '" "' + params + '"';
288300
break;
289301
default:
290302
break;

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
22
"name": "virtualbox",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "A library to interact with VirtualBox.",
55
"author": "Azer Koculu <[email protected]>",
6-
"licenses": [
7-
{
8-
"type": "MIT",
9-
"url": "https://raw.githubusercontent.com/Node-Virtualization/node-virtualbox/master/LICENSE"
10-
}
11-
],
6+
"license": "MIT",
127
"bugs": "https://github.com/Node-Virtualization/node-virtualbox/issues",
138
"contributors": [
149
{
@@ -18,7 +13,7 @@
1813
},
1914
{
2015
"name": "Michael Sanford",
21-
"url": "http://michaelsanford.com"
16+
"url": "http://accidentalbeard.com"
2217
},
2318
{
2419
"name": "Steffen Roegner",

0 commit comments

Comments
 (0)