Script fetching Nimbledroid data should return a proper exit code

See this issue for details:
https://github.com/mozilla/firefox-health-dashboard/issues/132#issuecomment-419163074

We also add more verbosity and build the project before calling the script to reflect
code changes to the script.
This commit is contained in:
Armen Zambrano G 2018-09-07 09:36:53 -04:00
Родитель efeb57bf87
Коммит 668d358922
2 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -15,7 +15,7 @@
"start:debugger": "neutrino build && node --inspect .",
"precommit": "lint-staged",
"heroku-postbuild": "npm run build",
"fetchNimbledroidData": "node build/nimbledroid.js"
"fetchNimbledroidData": "neutrino build && node build/nimbledroid.js"
},
"lint-staged": {
"*.js": [

Просмотреть файл

@ -35,6 +35,8 @@ const storeProfilingRunIfMissing = async (profilingRunData) => {
if (!cached) {
console.log(`Storing ${key}`);
await redisClient.set(key, JSON.stringify(profilingRunData));
} else {
console.log(`The key is already in the cache (${key})`);
}
}
};
@ -48,17 +50,20 @@ const fetchData = async productName =>
nimbledroidClient.getNimbledroidData(productName);
const main = async () => {
let errorCode = -1;
console.log('Fetching each product can take between 20-40 seconds.');
try {
await Promise.all(['klar', 'focus'].map(async (productName) => {
console.log(`Fetching ${productName}`);
const productData = await fetchData(productName);
console.log(`Storing ${productName}`);
await storeDataInRedis(productData);
}));
errorCode = 0;
} catch (e) {
console.error(e);
} finally {
process.exit();
process.exit(errorCode);
}
};