mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-25 17:45:48 +02:00
Make getDefaultPreferences a synchronous function, to simplify the build scripts
This commit is contained in:
parent
06cf7dd7b0
commit
2a83f955b0
28
gulpfile.mjs
28
gulpfile.mjs
@ -888,12 +888,15 @@ function buildDefaultPreferences(defines, dir) {
|
|||||||
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + dir));
|
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseDefaultPreferences(dir) {
|
function getDefaultPreferences(dir) {
|
||||||
console.log();
|
console.log();
|
||||||
console.log("### Parsing default preferences");
|
console.log("### Parsing default preferences");
|
||||||
|
|
||||||
// eslint-disable-next-line no-unsanitized/method
|
const require = process
|
||||||
const { AppOptions, OptionKind } = await import(
|
.getBuiltinModule("module")
|
||||||
|
.createRequire(import.meta.url);
|
||||||
|
|
||||||
|
const { AppOptions, OptionKind } = require(
|
||||||
"./" + DEFAULT_PREFERENCES_DIR + dir + "app_options.mjs"
|
"./" + DEFAULT_PREFERENCES_DIR + dir + "app_options.mjs"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -904,18 +907,7 @@ async function parseDefaultPreferences(dir) {
|
|||||||
if (Object.keys(prefs).length === 0) {
|
if (Object.keys(prefs).length === 0) {
|
||||||
throw new Error("No default preferences found.");
|
throw new Error("No default preferences found.");
|
||||||
}
|
}
|
||||||
|
return prefs;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultFtl() {
|
function getDefaultFtl() {
|
||||||
@ -1306,9 +1298,6 @@ gulp.task(
|
|||||||
const defines = { ...DEFINES, MOZCENTRAL: true };
|
const defines = { ...DEFINES, MOZCENTRAL: true };
|
||||||
return buildDefaultPreferences(defines, "mozcentral/");
|
return buildDefaultPreferences(defines, "mozcentral/");
|
||||||
},
|
},
|
||||||
async function prefsMozcentral() {
|
|
||||||
await parseDefaultPreferences("mozcentral/");
|
|
||||||
},
|
|
||||||
function createMozcentral() {
|
function createMozcentral() {
|
||||||
console.log();
|
console.log();
|
||||||
console.log("### Building mozilla-central extension");
|
console.log("### Building mozilla-central extension");
|
||||||
@ -1424,9 +1413,6 @@ gulp.task(
|
|||||||
createTemporaryScriptingBundle(defines),
|
createTemporaryScriptingBundle(defines),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
async function prefsChromium() {
|
|
||||||
await parseDefaultPreferences("chromium/");
|
|
||||||
},
|
|
||||||
function createChromium() {
|
function createChromium() {
|
||||||
console.log();
|
console.log();
|
||||||
console.log("### Building Chromium extension");
|
console.log("### Building Chromium extension");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user