Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit fe89fe4

Browse files
committed
docs: document profiles methods
1 parent 142a373 commit fe89fe4

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

SPEC/CONFIG.md

+59
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* [config.get](#configget)
44
* [config.set](#configset)
55
* [config.replace](#configreplace)
6+
* [config.profiles.list](#configprofileslist)
7+
* [config.profiles.apply](#configprofilesapply)
68

79
#### `config.get`
810

@@ -85,5 +87,62 @@ ipfs.config.replace(newConfig, (err) => {
8587

8688
A great source of [examples][] can be found in the tests for this API.
8789

90+
#### `config.profiles.list`
91+
92+
> List available config profiles
93+
94+
##### `ipfs.config.profiles.list([options], [callback])`
95+
96+
`options` is a object.
97+
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful.
98+
99+
If no callback is passed, a [promise][] is returned
100+
101+
**Example:**
102+
103+
```JavaScript
104+
ipfs.config.profiles.list(newConfig, (err, profiles) => {
105+
if (err) {
106+
throw err
107+
}
108+
109+
profiles.forEach(profile => {
110+
console.info(profile.name, profile.description)
111+
})
112+
})
113+
```
114+
115+
A great source of [examples][] can be found in the tests for this API.
116+
117+
#### `config.profiles.apply`
118+
119+
> Apply a config profile
120+
121+
##### `ipfs.config.profiles.apply(name, [options], [callback])`
122+
123+
`name` is a string. Call `config.profiles.list()` for a list of valid profile names.
124+
`options` an object that might contain the following values:
125+
- `dryRun` is a boolean which if true does not apply the profile
126+
`callback` must follow the `function (err, result) {}` signature, where `err` is an error if the operation was not successful.
127+
128+
If no callback is passed, a [promise][] is returned
129+
130+
**Example:**
131+
132+
```JavaScript
133+
ipfs.config.profiles.apply('lowpower', (err, diff) => {
134+
if (err) {
135+
throw err
136+
}
137+
138+
console.info(diff.old)
139+
console.info(diff.new)
140+
})
141+
```
142+
143+
Note that you will need to restart your node for config changes to take effect.
144+
145+
A great source of [examples][] can be found in the tests for this API.
146+
88147
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
89148
[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/config

src/config/profiles/apply.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ module.exports = (createCommon, options) => {
3636
(cb) => ipfs.config.profiles.apply('lowpower', cb),
3737
(_diff, cb) => {
3838
diff = _diff
39-
expect(diff.oldCfg.Swarm.ConnMgr.LowWater).to.not.equal(diff.newCfg.Swarm.ConnMgr.LowWater)
39+
expect(diff.old.Swarm.ConnMgr.LowWater).to.not.equal(diff.new.Swarm.ConnMgr.LowWater)
4040
ipfs.config.get(cb)
4141
},
4242
(newConfig, cb) => {
43-
expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.newCfg.Swarm.ConnMgr.LowWater)
43+
expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.new.Swarm.ConnMgr.LowWater)
4444
cb()
4545
}
4646
], done)

0 commit comments

Comments
 (0)