Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
refactor: use optional chaining / nullish coalescing operator (electr…
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and khalwa committed Feb 22, 2023
1 parent b210f9e commit cfe6196
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/asar/fs-wrapper.ts
Expand Up @@ -60,8 +60,8 @@ const splitPath = (archivePathOrBuffer: string | Buffer) => {
// Convert asar archive's Stats object to fs's Stats object.
let nextInode = 0;

const uid = process.getuid != null ? process.getuid() : 0;
const gid = process.getgid != null ? process.getgid() : 0;
const uid = process.getuid?.() ?? 0;
const gid = process.getgid?.() ?? 0;

const fakeTime = new Date();

Expand Down
2 changes: 1 addition & 1 deletion lib/browser/api/auto-updater/squirrel-update-win.ts
Expand Up @@ -68,7 +68,7 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
if (code !== 0) {
// Disabled for backwards compatibility:
// 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.
Expand Down
3 changes: 1 addition & 2 deletions lib/browser/api/desktop-capturer.ts
Expand Up @@ -9,8 +9,7 @@ let currentlyRunning: {

// |options.types| can't be empty and must be an array
function isValid (options: Electron.SourcesOptions) {
const types = options ? options.types : undefined;
return Array.isArray(types);
return Array.isArray(options?.types);
}

export async function getSources (args: Electron.SourcesOptions) {
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/api/touch-bar.ts
Expand Up @@ -395,7 +395,7 @@ class TouchBar extends EventEmitter implements Electron.TouchBar {
this.on('change', changeListener);

const escapeItemListener = (item: Electron.TouchBarItemType | null) => {
window._setEscapeTouchBarItem(item != null ? item : {});
window._setEscapeTouchBarItem(item ?? {});
};
this.on('escape-item-change', escapeItemListener);

Expand Down
4 changes: 2 additions & 2 deletions lib/browser/guest-view-manager.ts
Expand Up @@ -38,8 +38,8 @@ function makeWebPreferences (embedder: Electron.WebContents, params: Record<stri
: null;

const webPreferences: Electron.WebPreferences = {
nodeIntegration: params.nodeintegration != null ? params.nodeintegration : false,
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes != null ? params.nodeintegrationinsubframes : false,
nodeIntegration: params.nodeintegration ?? false,
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes ?? false,
plugins: params.plugins,
zoomFactor: embedder.zoomFactor,
disablePopups: !params.allowpopups,
Expand Down

0 comments on commit cfe6196

Please sign in to comment.