Merge pull request #889 from embark-framework/bugfix/ipfs-hash-fetch

Fetch IPFS dir hash deterministically
This commit is contained in:
Iuri Matias 2018-09-21 18:29:24 -04:00 committed by GitHub
commit 681dddbbf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -2,8 +2,9 @@ require('colors');
let async = require('async');
let shelljs = require('shelljs');
class IPFS {
const path = require('path');
class IPFS {
constructor(options) {
this.options = options;
this.buildDir = options.buildDir || 'dist/';
@ -35,11 +36,11 @@ class IPFS {
});
},
function getHashFromOutput(result, callback) {
let rows = result.split("\n");
let dir_row = rows[rows.length - 2];
let dir_hash = dir_row.split(" ")[1];
const pattern = `added ([a-zA-Z1-9]{46}) ${path.basename(self.buildDir)}\n`;
const regex = RegExp(pattern, 'm');
const dirHash = result.match(regex)[1];
callback(null, dir_hash);
callback(null, dirHash);
},
function printUrls(dir_hash, callback) {
console.log(("=== " + __("DApp available at") + " http://localhost:8080/ipfs/" + dir_hash + "/").green);