mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02: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).
|
- [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.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.
|
- [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.
|
- [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.
|
- [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';
|
'use strict';
|
||||||
|
|
||||||
const { glob } = require('glob');
|
const { glob } = require('glob');
|
||||||
|
const { sep } = require('path');
|
||||||
|
|
||||||
function parsePlatform(pagefile) {
|
function parsePlatform(pagefile) {
|
||||||
return pagefile.split(/\//)[1];
|
return pagefile.split(sep)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePagename(pagefile) {
|
function parsePagename(pagefile) {
|
||||||
return pagefile.split(/\//)[2].replace(/\.md$/, '');
|
return pagefile.split(sep)[2].replace(/\.md$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseLanguage(pagefile) {
|
function parseLanguage(pagefile) {
|
||||||
let pagesFolder = pagefile.split(/\//)[0];
|
let pagesFolder = pagefile.split(sep)[0];
|
||||||
return pagesFolder == 'pages' ? 'en' : pagesFolder.replace(/^pages\./, '');
|
return pagesFolder == 'pages' ? 'en' : pagesFolder.replace(/^pages\./, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ function buildPagesIndex(files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const targets = index[page].targets;
|
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) {
|
if (!exists) {
|
||||||
targets.push({os, language})
|
targets.push({os, language})
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,6 @@ function saveIndex(index) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error('ERROR building index!');
|
console.error('ERROR building index!');
|
||||||
console.error(er);
|
console.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue