[ESM] Convert the external/importL10n-folder to use standard modules

This commit is contained in:
Jonas Jenwald 2023-07-08 09:29:51 +02:00
parent 5696c3aa3a
commit a650fcd634
3 changed files with 10 additions and 16 deletions

View File

@ -7,7 +7,7 @@
], ],
"parserOptions": { "parserOptions": {
"sourceType": "script", "sourceType": "module",
}, },
"plugins": [ "plugins": [

View File

@ -13,11 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
"use strict"; import fs from "fs";
import https from "https";
const fs = require("fs"); import path from "path";
const https = require("https");
const path = require("path");
// Fetches all languages that have an *active* translation in mozilla-central. // Fetches all languages that have an *active* translation in mozilla-central.
// This is used in gulpfile.js for the `importl10n` command. // This is used in gulpfile.js for the `importl10n` command.
@ -112,7 +110,7 @@ function downloadLanguageFiles(root, langCode) {
}); });
} }
async function downloadL10n(root, callback) { async function downloadL10n(root) {
const langCodes = await downloadLanguageCodes(); const langCodes = await downloadLanguageCodes();
for (const langCode of langCodes) { for (const langCode of langCodes) {
@ -142,10 +140,6 @@ async function downloadL10n(root, callback) {
"\n" "\n"
); );
} }
if (callback) {
callback();
}
} }
exports.downloadL10n = downloadL10n; export { downloadL10n };

View File

@ -1880,7 +1880,7 @@ gulp.task("lint", function (done) {
const esLintOptions = [ const esLintOptions = [
"node_modules/eslint/bin/eslint", "node_modules/eslint/bin/eslint",
"--ext", "--ext",
".js,.jsm,.json", ".js,.jsm,.mjs,.json",
".", ".",
"--report-unused-disable-directives", "--report-unused-disable-directives",
]; ];
@ -2004,8 +2004,8 @@ gulp.task("clean", function (done) {
rimraf(BUILD_DIR, done); rimraf(BUILD_DIR, done);
}); });
gulp.task("importl10n", function (done) { gulp.task("importl10n", async function () {
const locales = require("./external/importL10n/locales.js"); const { downloadL10n } = await import("./external/importL10n/locales.mjs");
console.log(); console.log();
console.log("### Importing translations from mozilla-central"); console.log("### Importing translations from mozilla-central");
@ -2013,7 +2013,7 @@ gulp.task("importl10n", function (done) {
if (!fs.existsSync(L10N_DIR)) { if (!fs.existsSync(L10N_DIR)) {
fs.mkdirSync(L10N_DIR); fs.mkdirSync(L10N_DIR);
} }
locales.downloadL10n(L10N_DIR, done); await downloadL10n(L10N_DIR);
}); });
function ghPagesPrepare() { function ghPagesPrepare() {