You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
feat: allow daemon to init and start in a single cmd
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.
ipfs/kubo#6489
`ipfs init` changed to accept a file path as an argument
`ipfs daemon` changed to support `--init` and `--init-config` options.
Now we can do `ipfs daemon --init --init-config /path/to/custom-config`
refs:
ipfs/js-ipfsd-ctl#303
Copy file name to clipboardExpand all lines: src/cli/commands/init.js
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
1
'use strict'
2
2
3
+
constfs=require('fs')
4
+
constdebug=require('debug')('ipfs:cli:init')
3
5
const{ ipfsPathHelp }=require('../utils')
4
6
5
7
module.exports={
6
-
command: 'init [config] [options]',
8
+
command: 'init [default-config] [options]',
7
9
describe: 'Initialize a local IPFS node',
8
10
builder(yargs){
9
11
returnyargs
10
12
.epilog(ipfsPathHelp)
11
-
.positional('config',{
12
-
describe: 'Node config, this should JSON and will be merged with the default config. Check https://github.com/ipfs/js-ipfs#optionsconfig',
13
+
.positional('default-config',{
14
+
describe: 'Initialize with the given configuration. Path to the config file. Check https://github.com/ipfs/js-ipfs#optionsconfig',
13
15
type: 'string'
14
16
})
15
17
.option('bits',{
@@ -34,6 +36,18 @@ module.exports = {
34
36
argv.resolve((async()=>{
35
37
constpath=argv.getRepoPath()
36
38
39
+
letconfig={}
40
+
// read and parse config file
41
+
if(argv.defaultConfig){
42
+
try{
43
+
constraw=fs.readFileSync(argv.defaultConfig)
44
+
config=JSON.parse(raw)
45
+
}catch(error){
46
+
debug(error)
47
+
thrownewError('Default config couldn\'t be found or content isn\'t valid JSON.')
0 commit comments