Use more optional chaining, and other modern JS, in the building code
This commit is contained in:
parent
fbcb683609
commit
f295c51cc5
@ -11,7 +11,7 @@ function isPDFJSPreprocessor(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function evalWithDefines(code, defines) {
|
function evalWithDefines(code, defines) {
|
||||||
if (!code || !code.trim()) {
|
if (!code?.trim()) {
|
||||||
throw new Error("No JavaScript expression given");
|
throw new Error("No JavaScript expression given");
|
||||||
}
|
}
|
||||||
return vm.runInNewContext(code, defines, { displayErrors: false });
|
return vm.runInNewContext(code, defines, { displayErrors: false });
|
||||||
@ -56,12 +56,7 @@ function handlePreprocessorAction(ctx, actionName, args, path) {
|
|||||||
throw new Error("Unsupported action");
|
throw new Error("Unsupported action");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw path.buildCodeFrameError(
|
throw path.buildCodeFrameError(
|
||||||
"Could not process " +
|
`Could not process ${PDFJS_PREPROCESSOR_NAME}.${actionName}: ${e.message}`
|
||||||
PDFJS_PREPROCESSOR_NAME +
|
|
||||||
"." +
|
|
||||||
actionName +
|
|
||||||
": " +
|
|
||||||
e.message
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
external/builder/builder.mjs
vendored
2
external/builder/builder.mjs
vendored
@ -84,7 +84,7 @@ function preprocess(inFilename, outFilename, defines) {
|
|||||||
out.push(line);
|
out.push(line);
|
||||||
};
|
};
|
||||||
function evaluateCondition(code) {
|
function evaluateCondition(code) {
|
||||||
if (!code || !code.trim()) {
|
if (!code?.trim()) {
|
||||||
throw new Error("No JavaScript expression given at " + loc());
|
throw new Error("No JavaScript expression given at " + loc());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -124,9 +124,8 @@ function transform(charEncoding, transformFunction) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeSpawnSync(command, parameters, options) {
|
function safeSpawnSync(command, parameters, options = {}) {
|
||||||
// Execute all commands in a shell.
|
// Execute all commands in a shell.
|
||||||
options = options || {};
|
|
||||||
options.shell = true;
|
options.shell = true;
|
||||||
// `options.shell = true` requires parameters to be quoted.
|
// `options.shell = true` requires parameters to be quoted.
|
||||||
parameters = parameters.map(param => {
|
parameters = parameters.map(param => {
|
||||||
@ -410,7 +409,7 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
|
|||||||
// Deprecated keys are allowed in the managed preferences file.
|
// Deprecated keys are allowed in the managed preferences file.
|
||||||
// The code maintainer is responsible for adding migration logic to
|
// The code maintainer is responsible for adding migration logic to
|
||||||
// extensions/chromium/options/migration.js and web/chromecom.js .
|
// extensions/chromium/options/migration.js and web/chromecom.js .
|
||||||
return !description || !description.startsWith("DEPRECATED.");
|
return !description?.startsWith("DEPRECATED.");
|
||||||
});
|
});
|
||||||
|
|
||||||
let ret = true;
|
let ret = true;
|
||||||
@ -520,7 +519,7 @@ function createSandboxExternal(defines) {
|
|||||||
|
|
||||||
function createTemporaryScriptingBundle(defines, extraOptions = undefined) {
|
function createTemporaryScriptingBundle(defines, extraOptions = undefined) {
|
||||||
return createScriptingBundle(defines, {
|
return createScriptingBundle(defines, {
|
||||||
disableVersionInfo: !!(extraOptions && extraOptions.disableVersionInfo),
|
disableVersionInfo: !!extraOptions?.disableVersionInfo,
|
||||||
disableSourceMaps: true,
|
disableSourceMaps: true,
|
||||||
disableLicenseHeader: true,
|
disableLicenseHeader: true,
|
||||||
}).pipe(gulp.dest(TMP_DIR));
|
}).pipe(gulp.dest(TMP_DIR));
|
||||||
|
Loading…
Reference in New Issue
Block a user