mirror of https://github.com/embarklabs/embark.git
refactor ipfs module
This commit is contained in:
parent
fb41ce8a66
commit
5ae091ffb5
43
lib/ipfs.js
43
lib/ipfs.js
|
@ -1,34 +1,29 @@
|
|||
require('shelljs/global');
|
||||
var colors = require('colors');
|
||||
|
||||
ipfs = function(build_dir) {
|
||||
ipfs_bin = exec('which ipfs').output.split("\n")[0]
|
||||
var IPFS = function(options) {
|
||||
this.options = options;
|
||||
this.buildDir = options.buildDir || 'dist/';
|
||||
};
|
||||
|
||||
IPFS.prototype.deploy = function() {
|
||||
var ipfs_bin = exec('which ipfs').output.split("\n")[0];
|
||||
|
||||
if (ipfs_bin==='ipfs not found'){
|
||||
console.log('=== WARNING: IPFS not in an executable path. Guessing ~/go/bin/ipfs for path')
|
||||
console.log('=== WARNING: IPFS not in an executable path. Guessing ~/go/bin/ipfs for path'.yellow);
|
||||
ipfs_bin = "~/go/bin/ipfs";
|
||||
}
|
||||
|
||||
cmd = ipfs_bin + " add -r " + build_dir;
|
||||
var cmd = ipfs_bin + " add -r " + build_dir;
|
||||
console.log(("=== adding " + cmd + " to ipfs").green);
|
||||
|
||||
console.log("=== adding " + cmd + " to ipfs");
|
||||
var result = exec(cmd);
|
||||
var rows = result.output.split("\n");
|
||||
var dir_row = rows[rows.length - 2];
|
||||
var dir_hash = dir_row.split(" ")[1];
|
||||
|
||||
result = exec(cmd);
|
||||
|
||||
rows = result.output.split("\n");
|
||||
|
||||
dir_row = rows[rows.length - 2];
|
||||
|
||||
dir_hash = dir_row.split(" ")[1];
|
||||
|
||||
console.log("=== DApp available at http://localhost:8080/ipfs/" + dir_hash + "/");
|
||||
|
||||
console.log("=== DApp available at http://gateway.ipfs.io/ipfs/" + dir_hash + "/");
|
||||
}
|
||||
|
||||
Release = {
|
||||
ipfs: ipfs
|
||||
}
|
||||
|
||||
module.exports = Release
|
||||
console.log(("=== DApp available at http://localhost:8080/ipfs/" + dir_hash + "/").green);
|
||||
console.log(("=== DApp available at http://gateway.ipfs.io/ipfs/" + dir_hash + "/").green);
|
||||
};
|
||||
|
||||
module.exports = IPFS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue