|
3 | 3 | const yargs_parser = require("yargs-parser");
|
4 | 4 | const path = require("path");
|
5 | 5 | const chalk = require("chalk");
|
| 6 | +const langs = require("./countries.json"); |
6 | 7 | const prompts = require("prompts");
|
7 | 8 | const semver = require("semver");
|
8 | 9 | const ora = require("ora");
|
@@ -66,31 +67,23 @@ const onLoad = async (targetDir, version) => {
|
66 | 67 |
|
67 | 68 | const questions = [
|
68 | 69 | {
|
69 |
| - type: "confirm", |
70 |
| - name: "jquery", |
71 |
| - message: "Remove jQuery?", |
72 |
| - initial: true, |
| 70 | + type: "autocomplete", |
| 71 | + name: "lang", |
| 72 | + message: "Select language", |
| 73 | + choices: langs, |
73 | 74 | },
|
74 |
| - // { |
75 |
| - // type: 'confirm', |
76 |
| - // name: 'docs', |
77 |
| - // message: 'Include docs?', |
78 |
| - // } |
79 | 75 | ];
|
80 | 76 |
|
81 |
| - const { jquery } = await prompts(questions); |
82 |
| - |
83 |
| - if (jquery) { |
84 |
| - try { |
85 |
| - const indexFile = targetDir + "/index.html"; |
86 |
| - const sourceHTML = await fs.readFile(indexFile, "utf-8"); |
87 |
| - const resultHTML = sourceHTML.replace( |
88 |
| - /(<script>window\.jQuery.*<\/script>|<script src=".*jquery.*<\/script>)/gi, |
89 |
| - "" |
90 |
| - ); |
91 |
| - await fs.writeFile(indexFile, resultHTML); |
92 |
| - } catch (err) { |
93 |
| - throw new Error(err); |
94 |
| - } |
| 77 | + const { lang } = await prompts(questions); |
| 78 | + try { |
| 79 | + const indexFile = targetDir + "/index.html"; |
| 80 | + const sourceHTML = await fs.readFile(indexFile, "utf-8"); |
| 81 | + const resultHTML = sourceHTML.replace( |
| 82 | + /(<html.*lang=)\"([^"]*)\"/gi, |
| 83 | + `$1"${lang}"` |
| 84 | + ); |
| 85 | + await fs.writeFile(indexFile, resultHTML); |
| 86 | + } catch (err) { |
| 87 | + throw new Error(err); |
95 | 88 | }
|
96 | 89 | };
|
0 commit comments