Skip to content

Commit

Permalink
Fix review comments:
Browse files Browse the repository at this point in the history
1. Error handling for dup creation
2. Help Params for versions
3. Copy
  • Loading branch information
gratcliff committed Jul 16, 2019
1 parent b34abe0 commit f112ea1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
22 changes: 13 additions & 9 deletions lib/versions/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ exports.run = async function({ opts }) {
auth: { user: key },
};

return request.post(`${config.host}/api/v1/version`, options).catch(err => {
let errorDesc;
try {
errorDesc = JSON.parse(err.error).description;
} catch (e) {
errorDesc = 'Failed to create a new version using your specified parameters.';
}
return Promise.reject(new Error(errorDesc));
});
return request
.post(`${config.host}/api/v1/version`, options)
.then(() => Promise.resolve(`Version ${version} created successfully`))
.catch(err => {
let errorDesc;
try {
errorDesc =
typeof err.error === 'string' ? JSON.parse(err.error).description : err.error.description;
} catch (e) {
errorDesc = 'Failed to create a new version using your specified parameters.';
}
return Promise.reject(new Error(errorDesc));
});
};
1 change: 1 addition & 0 deletions lib/versions/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.run = async function({ opts }) {
.delete(`${config.host}/api/v1/version/${version}`, {
auth: { user: key },
})
.then(() => Promise.resolve(`Version ${version} deleted successfully`))
.catch(err => {
let errorDesc;
try {
Expand Down
1 change: 1 addition & 0 deletions lib/versions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const config = require('config');
exports.desc = 'List versions available in your project';
exports.category = 'services';
exports.weight = 3;
exports.action = 'versions';

exports.run = function({ opts }) {
const { key } = opts;
Expand Down
2 changes: 1 addition & 1 deletion lib/versions/versionId.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const request = require('request-promise-native');
const config = require('config');

exports.desc = 'List versions available in your project';
exports.desc = 'Get a specific version from your project';
exports.category = 'services';
exports.weight = 4;
exports.action = 'versions:versionId';
Expand Down

0 comments on commit f112ea1

Please sign in to comment.