File tree 3 files changed +22
-17
lines changed
3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 42
42
"cover" : " babel-node node_modules/.bin/isparta cover --root src --report html node_modules/.bin/_mocha -- $npm_package_options_mocha" ,
43
43
"coveralls" : " babel-node node_modules/.bin/isparta cover --root src --report lcovonly node_modules/.bin/_mocha -- $npm_package_options_mocha && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" ,
44
44
"build" : " npm run download && npm run build-public" ,
45
- "download" : " sh scripts/download " ,
45
+ "download" : " babel-node src/api/cachedData/downloadCache.js src/api/cachedData/cache.json " ,
46
46
"build-public" : " scripts/build-public" ,
47
47
"deploy" : " scripts/build-public && scripts/deploy-public" ,
48
48
"pretty" : " node scripts/pretty.js" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
/* eslint-disable no-sync */
2
2
3
3
import { URL } from 'url' ;
4
+ import { existsSync , writeFileSync } from 'fs' ;
4
5
import fetch from 'isomorphic-fetch' ;
5
6
6
7
/**
@@ -46,11 +47,24 @@ async function cacheResource(resourseName) {
46
47
} while ( url !== null ) ;
47
48
}
48
49
49
- Promise . all ( resources . map ( cacheResource ) )
50
- . then ( ( ) => {
51
- console . log ( JSON . stringify ( cache , null , 2 ) ) ;
52
- } )
53
- . catch ( function ( err ) {
54
- console . error ( err ) ;
55
- } ) ;
50
+ const outfile = process . argv [ 2 ] ;
51
+ if ( ! outfile ) {
52
+ console . error ( 'Missing ouput file!' ) ;
53
+ process . exit ( 1 ) ;
54
+ }
55
+
56
+ if ( ! existsSync ( outfile ) ) {
57
+ console . log ( 'Downloading cache...' ) ;
58
+
59
+ Promise . all ( resources . map ( cacheResource ) )
60
+ . then ( ( ) => {
61
+ const data = JSON . stringify ( cache , null , 2 ) ;
62
+ writeFileSync ( outfile , data , 'utf-8' ) ;
63
+ console . log ( 'Cached!' ) ;
64
+ } )
65
+ . catch ( function ( err ) {
66
+ console . error ( err ) ;
67
+ process . exit ( 1 ) ;
68
+ } ) ;
69
+ }
56
70
/* eslint-enable no-console */
You can’t perform that action at this time.
0 commit comments