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

Commit 5b8b8d6

Browse files
committed
feat: add support to pass config in the init cmd
1 parent 879802a commit 5b8b8d6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/cli/commands/init.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ const utils = require('../utils')
44
const print = utils.print
55

66
module.exports = {
7-
command: 'init',
8-
7+
command: 'init [config] [options]',
98
describe: 'Initialize a local IPFS node',
10-
119
builder (yargs) {
1210
return yargs
1311
.epilog(utils.ipfsPathHelp)
12+
.positional('config', {
13+
describe: 'Node config, this should JSON and will be merged with the default config. Check https://github.com/ipfs/js-ipfs#optionsconfig',
14+
type: 'string'
15+
})
1416
.option('bits', {
1517
type: 'number',
1618
alias: 'b',
@@ -41,7 +43,8 @@ module.exports = {
4143
const node = new IPFS({
4244
repo: new Repo(path),
4345
init: false,
44-
start: false
46+
start: false,
47+
config: argv.config
4548
})
4649

4750
node.init({

src/core/components/init.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const peerId = require('peer-id')
44
const waterfall = require('async/waterfall')
55
const parallel = require('async/parallel')
66
const promisify = require('promisify-es6')
7+
const extend = require('deep-extend')
78
const defaultConfig = require('../runtime/config-nodejs.js')
89
const Keychain = require('libp2p-keychain')
910

@@ -50,7 +51,8 @@ module.exports = function init (self) {
5051
opts.emptyRepo = opts.emptyRepo || false
5152
opts.bits = Number(opts.bits) || 2048
5253
opts.log = opts.log || function () {}
53-
const config = defaultConfig()
54+
55+
const config = extend(defaultConfig(), self._options.config)
5456
let privateKey
5557

5658
waterfall([

0 commit comments

Comments
 (0)