Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: add support to pass config in the init cmd (#1662)
Browse files Browse the repository at this point in the history
* feat: add support to pass config in the init cmd

* fix: use defaults-deep
  • Loading branch information
hugomrdias authored and daviddias committed Oct 31, 2018
1 parent 8e963f9 commit 588891c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 588891c

Please sign in to comment.