[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": {
"sourceType": "script",
"sourceType": "module",
},
"plugins": [

View File

@ -13,11 +13,9 @@
* limitations under the License.
*/
"use strict";
const fs = require("fs");
const https = require("https");
const path = require("path");
import fs from "fs";
import https from "https";
import path from "path";
// Fetches all languages that have an *active* translation in mozilla-central.
// 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();
for (const langCode of langCodes) {
@ -142,10 +140,6 @@ async function downloadL10n(root, callback) {
"\n"
);
}
if (callback) {
callback();
}
}
exports.downloadL10n = downloadL10n;
export { downloadL10n };

View File

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