mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 17:33:18 +00:00
Fix temporary os download output option in device init
This commit is contained in:
parent
ae8c941bfe
commit
3bc71577b5
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, osAction, path, resin, vcs, visuals;
|
||||
var _, async, commandOptions, osAction, path, resin, tmp, vcs, visuals;
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -13,6 +13,10 @@
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
tmp = require('tmp');
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
osAction = require('./os');
|
||||
@ -137,10 +141,27 @@
|
||||
return done();
|
||||
}
|
||||
options.yes = confirmed;
|
||||
return osAction.download.action(params, options, callback);
|
||||
}, function(outputFile, callback) {
|
||||
return tmp.file({
|
||||
prefix: 'resin-image-',
|
||||
postfix: '.img'
|
||||
}, callback);
|
||||
}, function(tmpPath, tmpFd, cleanupCallback, callback) {
|
||||
options.output = tmpPath;
|
||||
return osAction.download.action(params, options, function(error, outputFile) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return callback(null, outputFile, cleanupCallback);
|
||||
});
|
||||
}, function(outputFile, cleanupCallback, callback) {
|
||||
params.image = outputFile;
|
||||
return osAction.install.action(params, options, callback);
|
||||
return osAction.install.action(params, options, function(error) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
cleanupCallback();
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
@ -4,6 +4,11 @@ async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
vcs = require('resin-vcs')
|
||||
tmp = require('tmp')
|
||||
|
||||
# Cleanup the temporary files even when an uncaught exception occurs
|
||||
tmp.setGracefulCleanup()
|
||||
|
||||
commandOptions = require('./command-options')
|
||||
osAction = require('./os')
|
||||
|
||||
@ -210,10 +215,23 @@ exports.init =
|
||||
(confirmed, callback) ->
|
||||
return done() if not confirmed
|
||||
options.yes = confirmed
|
||||
osAction.download.action(params, options, callback)
|
||||
|
||||
(outputFile, callback) ->
|
||||
tmp.file
|
||||
prefix: 'resin-image-'
|
||||
postfix: '.img'
|
||||
, callback
|
||||
|
||||
(tmpPath, tmpFd, cleanupCallback, callback) ->
|
||||
options.output = tmpPath
|
||||
osAction.download.action params, options, (error, outputFile) ->
|
||||
return callback(error) if error?
|
||||
return callback(null, outputFile, cleanupCallback)
|
||||
|
||||
(outputFile, cleanupCallback, callback) ->
|
||||
params.image = outputFile
|
||||
osAction.install.action(params, options, callback)
|
||||
osAction.install.action params, options, (error) ->
|
||||
return callback(error) if error?
|
||||
cleanupCallback()
|
||||
return callback()
|
||||
|
||||
], done)
|
||||
|
@ -66,6 +66,7 @@
|
||||
"resin-sdk": "^1.2.0",
|
||||
"resin-settings-client": "^1.0.0",
|
||||
"resin-vcs": "^1.2.0",
|
||||
"tmp": "^0.0.25",
|
||||
"underscore.string": "~2.4.0",
|
||||
"update-notifier": "^0.3.1"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user