Fetch IPFS dir hash deterministically
This commit is contained in:
parent
636e5a09ac
commit
0bdafc273f
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue