Skip to content

Commit

Permalink
Handle app_settings upload errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jul 17, 2017
1 parent ae9dd5a commit 5dd5b86
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/fn/upload-app-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ const fs = require('../lib/sync-fs');
const request = require('request-promise-native');

module.exports = (project, couchUrl) => {
return request.put({
method: 'PUT',
url: `${couchUrl}/_design/medic/_rewrite/update_settings/medic?replace=1`,
headers: { 'Content-Type':'application/json' },
body: fs.read(`${project}/app_settings.json`),
});
return request
.put({
method: 'PUT',
url: `${couchUrl}/_design/medic/_rewrite/update_settings/medic?replace=1`,
headers: { 'Content-Type':'application/json' },
body: fs.read(`${project}/app_settings.json`),
})
.then(JSON.parse)
.then(json => {
// As per https://github.com/medic/medic-webapp/issues/3674, this endpoint
// will return 200 even when upload fails.
if(!json.success) throw new Error(json.error);
});
};

0 comments on commit 5dd5b86

Please sign in to comment.