From adcf08075f2c0675acd4604326750914bc9a734e Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Thu, 4 Jun 2020 14:49:00 +0100 Subject: [PATCH 1/3] fix: fix ipfs config show This PR `ipfs config show` work again and makes `config.get` first arg required --- docs/core-api/CONFIG.md | 4 ++-- .../interface-ipfs-core/src/config/get.js | 20 ++++++++++++++++++- packages/ipfs/src/cli/commands/config/show.js | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/core-api/CONFIG.md b/docs/core-api/CONFIG.md index bed36f0e40..b1568609eb 100644 --- a/docs/core-api/CONFIG.md +++ b/docs/core-api/CONFIG.md @@ -26,7 +26,7 @@ - [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. @@ -34,7 +34,7 @@ | 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 diff --git a/packages/interface-ipfs-core/src/config/get.js b/packages/interface-ipfs-core/src/config/get.js index 6aac0c84d3..2135ae3d77 100644 --- a/packages/interface-ipfs-core/src/config/get.js +++ b/packages/interface-ipfs-core/src/config/get.js @@ -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) @@ -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('', { timeout: 0 }) + + 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() diff --git a/packages/ipfs/src/cli/commands/config/show.js b/packages/ipfs/src/cli/commands/config/show.js index cd85c8c787..b48cf455aa 100644 --- a/packages/ipfs/src/cli/commands/config/show.js +++ b/packages/ipfs/src/cli/commands/config/show.js @@ -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)) From 3e609684766deb469535deb5e21eee584ba0e1fa Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Thu, 4 Jun 2020 15:18:34 +0100 Subject: [PATCH 2/3] fix: fix test options --- packages/interface-ipfs-core/src/config/get.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/interface-ipfs-core/src/config/get.js b/packages/interface-ipfs-core/src/config/get.js index 2135ae3d77..c09503cb9b 100644 --- a/packages/interface-ipfs-core/src/config/get.js +++ b/packages/interface-ipfs-core/src/config/get.js @@ -45,8 +45,8 @@ module.exports = (common, options) => { expect(config).to.be.an('object') }) - it('should retrieve the whole config with options', async () => { - const config = await ipfs.config.get('', { timeout: 0 }) + it.only('should retrieve the whole config with options', async () => { + const config = await ipfs.config.get('', { signal: null }) expect(config).to.be.an('object') }) From b754b9128aa38df80e9aed170099f104486bbbf8 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Thu, 4 Jun 2020 15:45:51 +0100 Subject: [PATCH 3/3] fix: remove only --- packages/interface-ipfs-core/src/config/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interface-ipfs-core/src/config/get.js b/packages/interface-ipfs-core/src/config/get.js index c09503cb9b..28a9c2a748 100644 --- a/packages/interface-ipfs-core/src/config/get.js +++ b/packages/interface-ipfs-core/src/config/get.js @@ -45,7 +45,7 @@ module.exports = (common, options) => { expect(config).to.be.an('object') }) - it.only('should retrieve the whole config with options', async () => { + it('should retrieve the whole config with options', async () => { const config = await ipfs.config.get('', { signal: null }) expect(config).to.be.an('object')