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:
parent
35951e7a3e
commit
7d3c5c37c7
2 changed files with 7 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue