|
1 | 1 | const fs = require("fs-extra"); |
2 | 2 | const path = require("path"); |
3 | | -// List of files to process |
4 | | -const filesToProcess = require("./generate-language-block-url.js"); |
| 3 | +const args = process.argv.slice(2); |
| 4 | +const lang = args[0].split(":")[1]; |
5 | 5 |
|
| 6 | +// List of files to process |
| 7 | +let filesToProcess = require("./generate-language-block-url.js"); |
| 8 | +const filesToProcessDealed = filesToProcess?.map( |
| 9 | + (file) => `docs/${lang}/${file}` |
| 10 | +); |
6 | 11 | // Regular expressions for English and Chinese blocks |
7 | 12 | const EN_BLOCK_REGEX = /<!-- #ifendef -->\s*([\s\S]*?)\s*<!-- #endendef -->/g; |
8 | 13 | const CN_BLOCK_REGEX = /<!-- #ifcndef -->\s*([\s\S]*?)\s*<!-- #endcndef -->/g; |
9 | 14 |
|
10 | 15 | async function processFiles(language, action) { |
11 | | - for (const file of filesToProcess) { |
| 16 | + for (const file of filesToProcessDealed) { |
12 | 17 | const filePath = path.resolve(file); |
13 | 18 | if (fs.existsSync(filePath)) { |
14 | 19 | let fileContent = await fs.readFile(filePath, "utf-8"); |
@@ -56,7 +61,6 @@ async function processFiles(language, action) { |
56 | 61 | } |
57 | 62 |
|
58 | 63 | // Run the appropriate function based on command line arguments |
59 | | -const args = process.argv.slice(2); |
60 | 64 | if (args[0] === "block_before:en") { |
61 | 65 | processFiles("en", "block_before"); |
62 | 66 | } else if (args[0] === "block_after:en") { |
|
0 commit comments