Skip to content

Commit c6dbe91

Browse files
committed
Use JSON for storing swapi cache
1 parent a6924f5 commit c6dbe91

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/node_modules
33
/npm-debug.log
44
/coverage
5-
/src/api/cachedData/cache.js
5+
/src/api/cachedData/cache.json

scripts/download

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -e
44

5-
if [ ! -s src/api/cachedData/cache.js ]; then
5+
if [ ! -s src/api/cachedData/cache.json ]; then
66
echo 'Downloading cache...'
7-
babel-node src/api/cachedData/downloadCache.js > src/api/cachedData/cache.js
7+
babel-node src/api/cachedData/downloadCache.js > src/api/cachedData/cache.json
88
echo 'Cached!'
99
fi

src/api/cachedData/downloadCache.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,7 @@ async function cacheResource(resourseName) {
4848

4949
Promise.all(resources.map(cacheResource))
5050
.then(() => {
51-
console.log(
52-
'/*eslint-disable */\n' +
53-
'/* Generated by combine.js */\n' +
54-
'// prettier-ignore\n' +
55-
'var data = {\n' +
56-
Object.keys(cache)
57-
.map(function(url) {
58-
return ' "' + url + '": ' + JSON.stringify(cache[url]);
59-
})
60-
.join(',\n') +
61-
'};\n' +
62-
'export default data;',
63-
);
51+
console.log(JSON.stringify(cache, null, 2));
6452
})
6553
.catch(function(err) {
6654
console.error(err);

0 commit comments

Comments
 (0)