Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(versions): stringify JSON for --raw option #404

Merged
merged 1 commit into from
Dec 13, 2021
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ rdme docs:edit <slug> --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
Expand Down
4 changes: 2 additions & 2 deletions __tests__/cmds/versions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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();
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/versions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down