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
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored and daviddias committed Oct 27, 2018
1 parent e1d4e6a commit 3079370
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 extend = require('deep-extend')
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 = extend(defaultConfig(), self._options.config)
let privateKey

waterfall([
Expand Down

0 comments on commit 3079370

Please sign in to comment.