From 2a83f955b052254aa8528ffb65eecefa346a44e6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 30 Jan 2026 09:32:41 +0100 Subject: [PATCH] Make `getDefaultPreferences` a synchronous function, to simplify the build scripts --- gulpfile.mjs | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/gulpfile.mjs b/gulpfile.mjs index e46b82292..858633d85 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -888,12 +888,15 @@ function buildDefaultPreferences(defines, dir) { .pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + dir)); } -async function parseDefaultPreferences(dir) { +function getDefaultPreferences(dir) { console.log(); console.log("### Parsing default preferences"); - // eslint-disable-next-line no-unsanitized/method - const { AppOptions, OptionKind } = await import( + const require = process + .getBuiltinModule("module") + .createRequire(import.meta.url); + + const { AppOptions, OptionKind } = require( "./" + DEFAULT_PREFERENCES_DIR + dir + "app_options.mjs" ); @@ -904,18 +907,7 @@ async function parseDefaultPreferences(dir) { if (Object.keys(prefs).length === 0) { throw new Error("No default preferences found."); } - - fs.writeFileSync( - DEFAULT_PREFERENCES_DIR + dir + "default_preferences.json", - JSON.stringify(prefs) - ); -} - -function getDefaultPreferences(dir) { - const str = fs - .readFileSync(DEFAULT_PREFERENCES_DIR + dir + "default_preferences.json") - .toString(); - return JSON.parse(str); + return prefs; } function getDefaultFtl() { @@ -1306,9 +1298,6 @@ gulp.task( const defines = { ...DEFINES, MOZCENTRAL: true }; return buildDefaultPreferences(defines, "mozcentral/"); }, - async function prefsMozcentral() { - await parseDefaultPreferences("mozcentral/"); - }, function createMozcentral() { console.log(); console.log("### Building mozilla-central extension"); @@ -1424,9 +1413,6 @@ gulp.task( createTemporaryScriptingBundle(defines), ]); }, - async function prefsChromium() { - await parseDefaultPreferences("chromium/"); - }, function createChromium() { console.log(); console.log("### Building Chromium extension");