src/tools/rustdoc-js/tester.js before after
+ time: stats.mtimeMs,
+ };
+ });
+ + if (matchingEntries.length === 0) {
+ + throw 'No static file matching regex';
+ + }
+ // We sort entries in descending order.
+ matchingEntries.sort((a, b) => b.time - a.time);
+ return matchingEntries[0].path;
const staticFiles = path.join(doc_folder, "static.files");
- const searchJs = fs.readdirSync(staticFiles).find(f => f.match(/search.*\.js$/));
- + const searchJs = mostRecentMatch(staticFiles, /search.*\.js$/);
+ + const searchJs = mostRecentMatch(staticFiles, /search-[0-9a-f]{8}.*\.js$/);
const searchModule = require(path.join(staticFiles, searchJs));
searchModule.initSearch(searchIndex.searchIndex);
const docSearch = searchModule.docSearch;