diff --git a/lib/drive/diskpart.coffee b/lib/drive/diskpart.coffee deleted file mode 100644 index 2a0f4e5f..00000000 --- a/lib/drive/diskpart.coffee +++ /dev/null @@ -1,45 +0,0 @@ -_ = require('lodash') -childProcess = require('child_process') -fs = require('fs') -path = require('path') -async = require('async') - -exports.runScript = (scriptPath, callback) -> - async.waterfall([ - - (callback) -> - fs.exists scriptPath, (exists) -> - if not exists - error = new Error("Diskpart script does not exist: #{scriptPath}") - return callback() - - (callback) -> - command = "diskpart /s \"#{scriptPath}\"" - childProcess.exec command, {}, (error, stdout, stderr) -> - return callback(new Error(stderr)) if not _.isEmpty(stderr) - return callback(null, stdout) - - ], callback) - -exports.getTempScriptPath = -> - currentTime = new Date().getTime() - return path.join(process.env.TEMP, "_diskpart-#{currentTime}") - -exports.evaluate = (input, callback) -> - - scriptFilePath = exports.getTempScriptPath() - - async.waterfall([ - - (callback) -> - fs.writeFile(scriptFilePath, input.join('\n'), callback) - - (callback) -> - exports.runScript(scriptFilePath, callback) - - (output, callback) -> - fs.unlink scriptFilePath, (error) -> - return callback(error) if error? - return callback(null, output) - - ], callback) diff --git a/lib/drive/win32.coffee b/lib/drive/win32.coffee index 3ce5951f..e27437d0 100644 --- a/lib/drive/win32.coffee +++ b/lib/drive/win32.coffee @@ -3,7 +3,7 @@ path = require('path') _ = require('lodash-contrib') async = require('async') fs = require('fs') -diskpart = require('./diskpart') +diskpart = require('diskpart') exports.rescanDrives = (callback) -> diskpart.evaluate([ 'rescan' ], callback) diff --git a/package.json b/package.json index 2c136391..b421aec2 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "author": "Juan Cruz Viotti ", "license": "MIT", "optionalDependencies": { - "windosu": "^0.1.3" + "windosu": "^0.1.3", + "diskpart": "^1.0.0" }, "devDependencies": { "chai": "~1.9.2",