Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Closed
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
4 changes: 2 additions & 2 deletions docs/core-api/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
- [Returns](#returns-4)
- [Example](#example-4)

## `ipfs.config.get([key,] [options])`
## `ipfs.config.get(key, [options])`

> Returns the currently being used config. If the daemon is off, it returns the stored config.

### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| key | `String` | The key of the value that should be fetched from the config file. If no key is passed, then the whole config will be returned. |
| key | `String` | The key of the value that should be fetched from the config file. An `undefined` or empty `string` value will return the full config object. |

### Options

Expand Down
20 changes: 19 additions & 1 deletion packages/interface-ipfs-core/src/config/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const testTimeout = require('../utils/test-timeout')
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
/**
* @param {Factory} common
* @param {Object} options
* @param {object} options
*/
module.exports = (common, options) => {
const describe = getDescribe(options)
Expand All @@ -33,6 +33,24 @@ module.exports = (common, options) => {
expect(config).to.be.an('object')
})

it('should retrieve the whole config with empty string', async () => {
const config = await ipfs.config.get('')

expect(config).to.be.an('object')
})

it('should retrieve the whole config with undefined', async () => {
const config = await ipfs.config.get(undefined)

expect(config).to.be.an('object')
})

it('should retrieve the whole config with options', async () => {
const config = await ipfs.config.get('', { signal: null })

expect(config).to.be.an('object')
})

it('should retrieve a value through a key', async () => {
const peerId = await ipfs.config.get('Identity.PeerID')
expect(peerId).to.exist()
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs/src/cli/commands/config/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
},

async handler ({ ctx: { ipfs, print }, timeout }) {
const config = await ipfs.config.get({
const config = await ipfs.config.get('', {
timeout
})
print(JSON.stringify(config, null, 4))
Expand Down