diff --git a/lib/modules/swarm/embarkjs.js b/lib/modules/swarm/embarkjs.js index f46b8681d..9a415258a 100644 --- a/lib/modules/swarm/embarkjs.js +++ b/lib/modules/swarm/embarkjs.js @@ -11,7 +11,7 @@ __embarkSwarm.setProvider = function (options) { this.connectError = new Error(`Cannot connect to Swarm node on ${this.connectUrl}`); this._getUrl = options.getUrl || `${this.connectUrl}/bzzr:/`; - var promise = new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { try { if (!this.bzz.currentProvider) { this.bzz.setProvider(`${options.protocol}://${options.host}:${options.port}`); @@ -22,7 +22,6 @@ __embarkSwarm.setProvider = function (options) { reject(this.connectError); } }); - return promise; }; __embarkSwarm.isAvailable = function () { @@ -72,9 +71,9 @@ __embarkSwarm.uploadFile = function (inputSelector) { } return new Promise((resolve, reject) => { - var reader = new FileReader(); + const reader = new FileReader(); reader.onloadend = (event) => { - var fileContent = new Uint8Array(event.target.result); + const fileContent = new Uint8Array(event.target.result); this.isAvailable().then((isAvailable) => { if (!isAvailable) { return reject(this.connectError); diff --git a/lib/modules/swarm/upload.js b/lib/modules/swarm/upload.js index 0c00aad8a..fbe64924a 100644 --- a/lib/modules/swarm/upload.js +++ b/lib/modules/swarm/upload.js @@ -28,6 +28,9 @@ class Swarm { .catch(callback); }, function printUrls(dir_hash, callback) { + if (!dir_hash) { + return callback('No directory hash was returned'); + } console.log((`=== DApp available at ${self.storageConfig.getUrl}${dir_hash}/`).green); callback(); @@ -36,9 +39,9 @@ class Swarm { if (err) { console.log("error uploading to swarm".red); console.log(err); - reject(err); + return reject(err); } - else resolve('successfully uploaded to swarm'); + resolve('successfully uploaded to swarm'); }); }); }