1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2024-10-30 02:17:56 +01:00

build-index: add error check, fix regexp typo

This commit is contained in:
Marco Bonelli 2019-04-02 20:19:02 +02:00 committed by Agniva De Sarker
parent e5d84c429b
commit 2fedf6ce96

View file

@ -12,7 +12,7 @@ function parsePagename(pagefile) {
function parseLanguage(pagefile) {
let pagesFolder = pagefile.split(/\//)[0];
return pagesFolder == 'pages' ? 'en' : pagesFolder.replace(/^pages./, '');
return pagesFolder == 'pages' ? 'en' : pagesFolder.replace(/^pages\./, '');
}
function buildPagesIndex(files) {
@ -58,6 +58,12 @@ function saveIndex(index) {
}
glob('pages*/**/*.md', function (er, files) {
if (er !== null) {
console.error('ERROR finding pages!');
console.error(er);
return;
}
let index = buildPagesIndex(files);
saveIndex(index);
});