1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-03-28 21:16:20 +01:00

scripts/build-index: Fix up script (#15903)

This commit is contained in:
RuiNtD 2025-03-25 19:02:49 -06:00 committed by GitHub
parent 35951e7a3e
commit 7d3c5c37c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View file

@ -11,7 +11,7 @@ This section contains a summary of the scripts available in this directory. For
- [pdf](pdf/README.md) directory contains the `render.py` and `build-pdf.sh` script and related resources to generate a PDF document of tldr-pages for a specific language or platform (or both).
- [build.sh](build.sh) script builds the ZIP archives of the `pages` directory.
- [build-index.sh](build-index.sh) script builds the index of available pages.
- [build-index.js](build-index.js) script builds the index of available pages.
- [check-pr.sh](check-pr.sh) script checks the page's syntax and performs various checks on the PR.
- [deploy.sh](deploy.sh) script deploys the ZIP and PDF archives to the static website repository.
- [send-to-bot.py](send-to-bot.py) is a Python script that sends the build or test output to tldr-bot.

View file

@ -3,17 +3,18 @@
'use strict';
const { glob } = require('glob');
const { sep } = require('path');
function parsePlatform(pagefile) {
return pagefile.split(/\//)[1];
return pagefile.split(sep)[1];
}
function parsePagename(pagefile) {
return pagefile.split(/\//)[2].replace(/\.md$/, '');
return pagefile.split(sep)[2].replace(/\.md$/, '');
}
function parseLanguage(pagefile) {
let pagesFolder = pagefile.split(/\//)[0];
let pagesFolder = pagefile.split(sep)[0];
return pagesFolder == 'pages' ? 'en' : pagesFolder.replace(/^pages\./, '');
}
@ -33,7 +34,7 @@ function buildPagesIndex(files) {
}
const targets = index[page].targets;
const exists = targets.some((t) => {return t.platform === os && t.language === language});
const exists = targets.some((t) => t.os === os && t.language === language);
if (!exists) {
targets.push({os, language})
}
@ -79,6 +80,6 @@ function saveIndex(index) {
process.exit(0);
}).catch((err) => {
console.error('ERROR building index!');
console.error(er);
console.error(err);
process.exit(1);
});