Skip to content

Commit

Permalink
Issue #132 - Script fetching Nimbledroid data should return a proper …
Browse files Browse the repository at this point in the history
…exit code

We also add more verbosity and build the project before calling the script to reflect
code changes to the script.
  • Loading branch information
armenzg committed Sep 7, 2018
1 parent efeb57b commit f1fac6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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": [
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/fetchNimbledroidData.js
Expand Up @@ -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})`);
}
}
};
Expand All @@ -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);
}
};

Expand Down

0 comments on commit f1fac6c

Please sign in to comment.