diff options
author | Evan Read <eread@gitlab.com> | 2023-03-06 05:16:41 +0300 |
---|---|---|
committer | David O'Regan <doregan@gitlab.com> | 2023-03-06 05:16:41 +0300 |
commit | a54039663d153148e32c8d658d51d7b1f17a863d (patch) | |
tree | 2d8ccf5f09b7ae1f6ff10193ea9c620b104ce16a /scripts | |
parent | 547451f7e5c1aace1cfc2e2fadd73c17ce17aabb (diff) |
Roll glob dependency forward
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lunr/preindex.js | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/scripts/lunr/preindex.js b/scripts/lunr/preindex.js index b883d9a0..088fd35c 100644 --- a/scripts/lunr/preindex.js +++ b/scripts/lunr/preindex.js @@ -16,20 +16,12 @@ const fs = require('fs'); const lunr = require('lunr'); const cheerio = require('cheerio'); -const glob = require('glob'); +const { glob } = require('glob'); const htmlSrc = 'public/'; const outputDir = `${htmlSrc}assets/javascripts`; -/** - * Find all HTML files within a given path, - * then execute a callback function to build the index. - */ -const buildIndex = (path, callback) => { - glob(`${path}/**/*.html`, callback); -}; - -/** +/* * Extracts text from a given HTML element. * * @param {cheerio} $ @@ -53,10 +45,8 @@ const getText = ($, element) => { /** * Build the index and output files. */ -buildIndex(htmlSrc, (err, filenames) => { - if (err) { - console.error(err); - } +(async () => { + const filenames = await glob(`${htmlSrc}/**/*.html`); // Create an array of objects containing each page's text content. const pages = []; @@ -103,4 +93,4 @@ buildIndex(htmlSrc, (err, filenames) => { console.error(fsErr); } }); -}); +})(); |