Eject Windows drives after successful burning

Use the `removedrive` for this task:

https://github.com/jviotti/removedrive

Fixes: https://github.com/resin-io/herostratus/issues/40
This commit is contained in:
Juan Cruz Viotti 2015-11-23 13:30:44 -04:00
parent a6ec66d0b3
commit da279820dc
2 changed files with 14 additions and 1 deletions

View File

@ -25,6 +25,12 @@ var imageWrite = require('resin-image-write');
var Promise = require('bluebird');
var umount = Promise.promisifyAll(require('umount'));
var fs = require('fs');
var os = require('os');
var isWindows = os.platform() === 'win32';
if (isWindows) {
var removedrive = Promise.promisifyAll(require('removedrive'));
}
/**
* @summary Get image readable stream
@ -86,6 +92,10 @@ exports.writeImage = function(image, drive, onProgress) {
writer.on('done', resolve);
});
}).then(function() {
return umount.umountAsync(drive.device);
if (isWindows && drive.mountpoint) {
return removedrive.ejectAsync(drive.mountpoint);
} else {
return umount.umountAsync(drive.device);
}
});
};

View File

@ -16,6 +16,9 @@
},
"author": "Juan Cruz Viotti <juan@resin.io>",
"license": "MIT",
"optionalDependencies": {
"removedrive": "^1.0.0"
},
"dependencies": {
"angular": "^1.4.6",
"angular-ui-bootstrap": "^0.14.2",