fix(scripts): better error handling for script runner and GDPR

This commit is contained in:
Sabe Jones
2018-10-12 15:27:31 +00:00
parent c64ea0a9a9
commit 6f5b9ef119
2 changed files with 14 additions and 8 deletions

View File

@@ -17,12 +17,12 @@ function setUpServer () {
setUpServer();
// Replace this with your migration
const processUsers = require('./users/takeThis.js');
const processUsers = require('../scripts/gdpr-delete-users.js');
processUsers()
.then(function success () {
process.exitCode = 0;
process.exit(0);
})
.catch(function failure (err) {
console.log(err);
process.exitCode = 1;
process.exit(1);
});

View File

@@ -20,9 +20,11 @@ async function _deleteAmplitudeData (userId, email) {
password: AMPLITUDE_SECRET,
},
}
);
).catch((err) => {
console.log(err.response.data);
});
console.log(`${response.status} ${response.statusText}`);
if (response) console.log(`${response.status} ${response.statusText}`);
}
async function _deleteHabiticaData (user) {
@@ -44,10 +46,14 @@ async function _deleteHabiticaData (user) {
'x-api-key': user.apiToken,
},
}
);
).catch((err) => {
console.log(err.response.data);
});
if (response) {
console.log(`${response.status} ${response.statusText}`);
if (response.status === 200) console.log(`${user._id} removed. Last login: ${user.auth.timestamps.loggedin}`);
}
}
async function _processEmailAddress (email) {