mirror of https://github.com/embarklabs/embark.git
more linting and add condition in case of no hash
This commit is contained in:
parent
2ad852667e
commit
3bf5093f1b
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue