Skip to content

Commit f49968c

Browse files
committed
Merge pull request #42 from jorisbontje/mkdirp-datadir
ensure datadir exists, bypassing the interactive liabilities prompt
2 parents 2bd14e5 + fb8eb8e commit f49968c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/blockchain.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var mkdirp = require('mkdirp');
12

23
Blockchain = function(blockchainConfig) {
34
this.config = blockchainConfig;
@@ -73,6 +74,14 @@ Blockchain.prototype.get_address = function() {
7374
var address = null;
7475

7576
if (config.account.init) {
77+
// ensure datadir exists, bypassing the interactive liabilities prompt.
78+
var newDir = mkdirp.sync(config.datadir);
79+
if (newDir) {
80+
console.log("=== datadir created");
81+
} else {
82+
console.log("=== datadir already exists");
83+
}
84+
7685
console.log("running: " + this.list_command());
7786
result = exec(this.list_command());
7887

@@ -96,4 +105,3 @@ Blockchain.prototype.startChain = function(use_tmp) {
96105
}
97106

98107
module.exports = Blockchain
99-

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"jasmine": "^2.3.1",
2020
"meteor-build-client": "^0.1.6",
2121
"methodmissing": "^0.0.3",
22+
"mkdirp": "^0.5.1",
2223
"python": "^0.0.4",
2324
"read-yaml": "^1.0.0",
2425
"shelljs": "^0.5.0",

0 commit comments

Comments
 (0)