From 087e0eb5d8ccc7e01bc49a88574105b0fc100c5e Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 13 Dec 2021 10:44:47 -0600 Subject: [PATCH] feat(versions): stringify JSON for `--raw` option --- README.md | 4 ++-- __tests__/cmds/versions.test.js | 4 ++-- src/cmds/versions/index.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9acff8342..db0a87237 100644 --- a/README.md +++ b/README.md @@ -93,14 +93,14 @@ rdme docs:edit --version={project-version} rdme versions ``` -If you wish to see the raw output from our API in this response, supply the `--raw` flag. +If you wish to see the raw JSON output from our API in this response, supply the `--raw` flag. #### Get All Information About a Particular Version ```sh rdme versions --version={project-version} ``` -If you wish to see the raw output from our API in this response, supply the `--raw` flag. +If you wish to see the raw JSON output from our API in this response, supply the `--raw` flag. #### Create a New Version ```sh diff --git a/__tests__/cmds/versions.test.js b/__tests__/cmds/versions.test.js index 8bef257ba..441fbe02f 100644 --- a/__tests__/cmds/versions.test.js +++ b/__tests__/cmds/versions.test.js @@ -64,7 +64,7 @@ describe('rdme versions*', () => { .reply(200, [versionPayload, version2Payload]); const response = await versions.run({ key, raw: true }); - expect(response).toStrictEqual([versionPayload, version2Payload]); + expect(response).toStrictEqual(JSON.stringify([versionPayload, version2Payload], null, 2)); mockRequest.done(); }); @@ -88,7 +88,7 @@ describe('rdme versions*', () => { .reply(200, versionPayload); return versions.run({ key, version, raw: true }).then(response => { - expect(response).toStrictEqual(versionPayload); + expect(response).toStrictEqual(JSON.stringify(versionPayload, null, 2)); mockRequest.done(); }); }); diff --git a/src/cmds/versions/index.js b/src/cmds/versions/index.js index 410f31173..f43fc0a9c 100644 --- a/src/cmds/versions/index.js +++ b/src/cmds/versions/index.js @@ -102,7 +102,7 @@ exports.run = function (opts) { } if (raw) { - return Promise.resolve(data); + return Promise.resolve(JSON.stringify(data, null, 2)); } let versions = data;