From 3bc94c163b35af013648a28f5cba21bd55bd9bb0 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Sun, 28 Jan 2018 10:09:33 +1300 Subject: [PATCH] feat: support for passphrase for js-ipfs daemons --- src/in-proc-node.js | 14 ++++++++++++-- src/utils/index.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/in-proc-node.js b/src/in-proc-node.js index 8ba6aa48..f06ac169 100644 --- a/src/in-proc-node.js +++ b/src/in-proc-node.js @@ -44,12 +44,22 @@ class Node { } }) - this.opts.EXPERIMENTAL.pubsub = (this.opts.args.indexOf('--enable-pubsub-experiment') > -1) - this.opts.EXPERIMENTAL.sharding = (this.opts.args.indexOf('--enable-sharding-experiment') > -1) + this.opts.args.forEach((arg) => { + if (arg === '--enable-pubsub-experiment') { + this.opts.EXPERIMENTAL.pubsub = true + } else if (arg === '--enable-sharding-experiment') { + this.opts.EXPERIMENTAL.sharding = true + } else if (arg.startsWith('--pass')) { + this.opts.pass = arg.split(' ').slice(1).join(' ') + } else { + throw new Error('Unkown argument ' + arg) + } + }) this.exec = new IPFS({ repo: this.repo, init: false, start: false, + pass: this.opts.pass, EXPERIMENTAL: this.opts.EXPERIMENTAL, libp2p: this.opts.libp2p }) diff --git a/src/utils/index.js b/src/utils/index.js index 63a462c2..18883359 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -89,7 +89,7 @@ exports.findIpfsExecutable = (type, rootPath) => { function run (node, args, opts, callback) { let executable = node.exec - if (isWindows && node.opts.type !== 'go') { + if (isWindows && executable.endsWith('.js')) { args = args || [] args.unshift(node.exec) executable = process.execPath