diff --git a/appstore.js b/appstore.js index b875a4f..b9b9c61 100644 --- a/appstore.js +++ b/appstore.js @@ -38,6 +38,13 @@ AppStore.prototype.getCloudrons = function () { return res.body.boxes; }; +AppStore.prototype.getCloudron = function (boxId) { + var res = request.get(this._origin + '/api/v1/cloudrons/' + boxId).query({ accessToken: this._credentials.accessToken, page: 1, per_page: 50 }).end(); + if (res.statusCode === 404) return null; + common.verifyResponse(res, 'Could not query cloudron status'); + return res.body.box; +}; + AppStore.prototype.waitForCloudron = function (boxId) { var creationTime = new Date(); process.stdout.write('Waiting for cloudron to come up.'); @@ -87,6 +94,15 @@ AppStore.prototype.deleteCloudron = function (box) { .send({ password: this._credentials.password }) .end(); common. verifyResponse(res, 'Could not delete cloudron'); + + process.stdout.write('Waiting for Cloudron to disappear.'); + while (true) { + if (this.getCloudron(box.id) === null) break; + + sleep(10); + + process.stdout.write('.'); + } }; AppStore.prototype.getManifest = function (appId, version) {