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

feat: add support to pass config in the init cmd #1662

Merged
merged 2 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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