refactor: use optional chaining / nullish coalescing operator (#35217)
This commit is contained in:
parent
76431ac1fa
commit
34b985c556
5 changed files with 7 additions and 8 deletions
|
@ -60,8 +60,8 @@ const splitPath = (archivePathOrBuffer: string | Buffer) => {
|
||||||
// Convert asar archive's Stats object to fs's Stats object.
|
// Convert asar archive's Stats object to fs's Stats object.
|
||||||
let nextInode = 0;
|
let nextInode = 0;
|
||||||
|
|
||||||
const uid = process.getuid != null ? process.getuid() : 0;
|
const uid = process.getuid?.() ?? 0;
|
||||||
const gid = process.getgid != null ? process.getgid() : 0;
|
const gid = process.getgid?.() ?? 0;
|
||||||
|
|
||||||
const fakeTime = new Date();
|
const fakeTime = new Date();
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
// Disabled for backwards compatibility:
|
// Disabled for backwards compatibility:
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
// eslint-disable-next-line standard/no-callback-literal
|
||||||
return callback(`Command failed: ${signal != null ? signal : code}\n${stderr}`);
|
return callback(`Command failed: ${signal ?? code}\n${stderr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success.
|
// Success.
|
||||||
|
|
|
@ -9,8 +9,7 @@ let currentlyRunning: {
|
||||||
|
|
||||||
// |options.types| can't be empty and must be an array
|
// |options.types| can't be empty and must be an array
|
||||||
function isValid (options: Electron.SourcesOptions) {
|
function isValid (options: Electron.SourcesOptions) {
|
||||||
const types = options ? options.types : undefined;
|
return Array.isArray(options?.types);
|
||||||
return Array.isArray(types);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSources (args: Electron.SourcesOptions) {
|
export async function getSources (args: Electron.SourcesOptions) {
|
||||||
|
|
|
@ -395,7 +395,7 @@ class TouchBar extends EventEmitter implements Electron.TouchBar {
|
||||||
this.on('change', changeListener);
|
this.on('change', changeListener);
|
||||||
|
|
||||||
const escapeItemListener = (item: Electron.TouchBarItemType | null) => {
|
const escapeItemListener = (item: Electron.TouchBarItemType | null) => {
|
||||||
window._setEscapeTouchBarItem(item != null ? item : {});
|
window._setEscapeTouchBarItem(item ?? {});
|
||||||
};
|
};
|
||||||
this.on('escape-item-change', escapeItemListener);
|
this.on('escape-item-change', escapeItemListener);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ function makeWebPreferences (embedder: Electron.WebContents, params: Record<stri
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const webPreferences: Electron.WebPreferences = {
|
const webPreferences: Electron.WebPreferences = {
|
||||||
nodeIntegration: params.nodeintegration != null ? params.nodeintegration : false,
|
nodeIntegration: params.nodeintegration ?? false,
|
||||||
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes != null ? params.nodeintegrationinsubframes : false,
|
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes ?? false,
|
||||||
plugins: params.plugins,
|
plugins: params.plugins,
|
||||||
zoomFactor: embedder.zoomFactor,
|
zoomFactor: embedder.zoomFactor,
|
||||||
disablePopups: !params.allowpopups,
|
disablePopups: !params.allowpopups,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue