diff --git a/src/cli/commands/init.js b/src/cli/commands/init.js index d7cbf090d1..9ff0cdef6a 100644 --- a/src/cli/commands/init.js +++ b/src/cli/commands/init.js @@ -4,13 +4,15 @@ const utils = require('../utils') const print = utils.print module.exports = { - command: 'init', - + command: 'init [config] [options]', describe: 'Initialize a local IPFS node', - builder (yargs) { return yargs .epilog(utils.ipfsPathHelp) + .positional('config', { + describe: 'Node config, this should JSON and will be merged with the default config. Check https://github.com/ipfs/js-ipfs#optionsconfig', + type: 'string' + }) .option('bits', { type: 'number', alias: 'b', @@ -41,7 +43,8 @@ module.exports = { const node = new IPFS({ repo: new Repo(path), init: false, - start: false + start: false, + config: argv.config }) node.init({ diff --git a/src/core/components/init.js b/src/core/components/init.js index eb91a09979..258e8a411a 100644 --- a/src/core/components/init.js +++ b/src/core/components/init.js @@ -4,6 +4,7 @@ const peerId = require('peer-id') const waterfall = require('async/waterfall') const parallel = require('async/parallel') const promisify = require('promisify-es6') +const defaultsDeep = require('@nodeutils/defaults-deep') const defaultConfig = require('../runtime/config-nodejs.js') const Keychain = require('libp2p-keychain') @@ -50,7 +51,8 @@ module.exports = function init (self) { opts.emptyRepo = opts.emptyRepo || false opts.bits = Number(opts.bits) || 2048 opts.log = opts.log || function () {} - const config = defaultConfig() + + const config = defaultsDeep(self._options.config, defaultConfig()) let privateKey waterfall([