diff --git a/lib/src/writer.js b/lib/src/writer.js index 26dd1dbb..12ed9c2d 100644 --- a/lib/src/writer.js +++ b/lib/src/writer.js @@ -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); + } }); }; diff --git a/package.json b/package.json index e89ea012..0bdd1f28 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ }, "author": "Juan Cruz Viotti ", "license": "MIT", + "optionalDependencies": { + "removedrive": "^1.0.0" + }, "dependencies": { "angular": "^1.4.6", "angular-ui-bootstrap": "^0.14.2",