Eugene Pankov 6 years ago
parent
commit
3f8b933d05
6 changed files with 44 additions and 41 deletions
  1. 3 2
      app/lib/app.ts
  2. 5 5
      app/lib/cli.ts
  3. 2 2
      app/lib/index.ts
  4. 7 5
      app/lib/lru.ts
  5. 21 21
      app/lib/sentry.ts
  6. 6 6
      app/lib/window.ts

+ 3 - 2
app/lib/app.ts

@@ -1,4 +1,5 @@
 import { app, ipcMain, Menu, Tray, shell } from 'electron'
+// eslint-disable-next-line no-duplicate-imports
 import * as electron from 'electron'
 import { loadConfig } from './config'
 import { Window, WindowOptions } from './window'
@@ -75,7 +76,7 @@ export class Application {
             this.tray = new Tray(`${app.getAppPath()}/assets/tray.png`)
         }
 
-        this.tray.on('click', () => setTimeout(() => this.focus()));
+        this.tray.on('click', () => setTimeout(() => this.focus()))
 
         const contextMenu = Menu.buildFromTemplate([{
             label: 'Show',
@@ -186,7 +187,7 @@ export class Application {
                         },
                     },
                 ],
-            }
+            },
         ]
 
         Menu.setApplicationMenu(Menu.buildFromTemplate(template))

+ 5 - 5
app/lib/cli.ts

@@ -20,25 +20,25 @@ export function parseArgs (argv, cwd) {
             return yargs.option('escape', {
                 alias: 'e',
                 type: 'boolean',
-                describe: 'Perform shell escaping'
+                describe: 'Perform shell escaping',
             }).positional('text', {
-                type: 'string'
+                type: 'string',
             })
         })
         .version('version', '', app.getVersion())
         .option('debug', {
             alias: 'd',
             describe: 'Show DevTools on start',
-            type: 'boolean'
+            type: 'boolean',
         })
         .option('hidden', {
             describe: 'Start minimized',
-            type: 'boolean'
+            type: 'boolean',
         })
         .option('version', {
             alias: 'v',
             describe: 'Show version and exit',
-            type: 'boolean'
+            type: 'boolean',
         })
         .help('help')
         .parse(argv.slice(1))

+ 2 - 2
app/lib/index.ts

@@ -59,8 +59,8 @@ app.on('ready', () => {
                 label: 'New window',
                 click () {
                     this.app.newWindow()
-                }
-            }
+                },
+            },
         ]))
     }
     application.init()

+ 7 - 5
app/lib/lru.ts

@@ -1,13 +1,15 @@
-let lru = require('lru-cache')({ max: 256, maxAge: 250 })
-
-let fs = require('fs')
-let origLstat = fs.realpathSync.bind(fs)
+import createLRU from 'lru-cache'
+import * as fs from 'fs'
+const lru = createLRU({ max: 256, maxAge: 250 })
+const origLstat = fs.realpathSync.bind(fs)
 
 // NB: The biggest offender of thrashing realpathSync is the node module system
 // itself, which we can't get into via any sane means.
 require('fs').realpathSync = function (p) {
     let r = lru.get(p)
-    if (r) return r
+    if (r) {
+        return r
+    }
 
     r = origLstat(p)
     lru.set(p, r)

+ 21 - 21
app/lib/sentry.ts

@@ -1,21 +1,21 @@
-const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer')
-import * as isDev from 'electron-is-dev'
-
-
-const SENTRY_DSN = 'https://[email protected]/181876'
-let release
-try {
-    release = require('electron').app.getVersion()
-} catch {
-    release = require('electron').remote.app.getVersion()
-}
-
-if (!isDev) {
-    init({
-        dsn: SENTRY_DSN,
-        release,
-        integrations (integrations) {
-            return integrations.filter(integration => integration.name !== 'Breadcrumbs')
-        },
-    })
-}
+const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer')
+import * as isDev from 'electron-is-dev'
+
+
+const SENTRY_DSN = 'https://[email protected]/181876'
+let release
+try {
+    release = require('electron').app.getVersion()
+} catch {
+    release = require('electron').remote.app.getVersion()
+}
+
+if (!isDev) {
+    init({
+        dsn: SENTRY_DSN,
+        release,
+        integrations (integrations) {
+            return integrations.filter(integration => integration.name !== 'Breadcrumbs')
+        },
+    })
+}

+ 6 - 6
app/lib/window.ts

@@ -56,14 +56,14 @@ export class Window {
 
         if (this.windowBounds) {
             Object.assign(bwOptions, this.windowBounds)
-            const closestDisplay = screen.getDisplayNearestPoint( {x: this.windowBounds.x, y: this.windowBounds.y} )
+            const closestDisplay = screen.getDisplayNearestPoint( { x: this.windowBounds.x, y: this.windowBounds.y } )
 
-            const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height];
-            const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height];
+            const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height]
+            const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height]
 
             if ((left2 > right1 || right2 < left1 || top2 > bottom1 || bottom2 < top1) && !maximized) {
-                bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2;
-                bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2;
+                bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2
+                bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2
             }
         }
 
@@ -150,7 +150,7 @@ export class Window {
     }
 
     isDestroyed () {
-        return !this.window || this.window.isDestroyed();
+        return !this.window || this.window.isDestroyed()
     }
 
     private setupWindowManagement () {