File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 3939 run : hugo --environment GitHubPages -d $GITHUB_WORKSPACE/dist --buildFuture
4040 - name : Generate Search index
4141 run : |
42- node ./assets/js/generate-lunr-index.js
42+ node ./assets/js/generate-lunr-index.js $GITHUB_WORKSPACE/dist
4343 - name : Test HTML
4444 uses : wjdp/htmltest-action@master
4545 with :
Original file line number Diff line number Diff line change 11const fs = require ( 'fs' ) ;
22const lunr = require ( 'lunr' ) ;
33
4- const data = JSON . parse ( fs . readFileSync ( './docs/offline-search-index.json' ) ) ;
4+ const args = process . argv . slice ( 2 ) ;
5+ const destination = args [ 0 ] ?? "." ;
6+
7+ const data = JSON . parse ( fs . readFileSync ( `${ destination } /docs/offline-search-index.json` ) ) ;
58
69const idx = lunr ( function ( ) {
710 this . ref ( 'ref' ) ;
@@ -21,4 +24,10 @@ const idx = lunr(function () {
2124 } ) ;
2225} ) ;
2326
24- fs . writeFileSync ( './assets/json/lunr-index.json' , JSON . stringify ( idx ) ) ;
27+ fs . writeFileSync ( `${ destination } /assets/json/lunr-index.json` , JSON . stringify ( idx ) ) ;
28+
29+ // check if file got created
30+ if ( ! fs . existsSync ( `${ destination } /assets/json/lunr-index.json` ) ) {
31+ console . error ( 'Failed to create lunr index' ) ;
32+ process . exit ( 1 ) ;
33+ }
You can’t perform that action at this time.
0 commit comments