mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-13 08:04:40 +08:00
fix(specs): silence noisy specs and fix warnings
Summary: Silence buffered process spec Clean up error reporter and spec bootup fix errors in draft store spec package manager spec and theme spec fixes Fix memory leak in draft store Test Plan: mmmmmm tests. Run all those green passing tests :) Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D1628
This commit is contained in:
parent
a716726c46
commit
e326547614
14 changed files with 320 additions and 247 deletions
|
@ -933,6 +933,8 @@ class ContenteditableComponent extends React.Component
|
||||||
document.execCommand("insertHTML", false, cleanHtml)
|
document.execCommand("insertHTML", false, cleanHtml)
|
||||||
@_selectionManuallyChanged = true
|
@_selectionManuallyChanged = true
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
# This is used primarily when pasting text in
|
# This is used primarily when pasting text in
|
||||||
_sanitizeInput: (inputText="", type="text/html") =>
|
_sanitizeInput: (inputText="", type="text/html") =>
|
||||||
if type is "text/plain"
|
if type is "text/plain"
|
||||||
|
|
|
@ -14,13 +14,13 @@ describe "BufferedProcess", ->
|
||||||
|
|
||||||
describe "when there is an error handler specified", ->
|
describe "when there is an error handler specified", ->
|
||||||
it "calls the error handler and does not throw an exception", ->
|
it "calls the error handler and does not throw an exception", ->
|
||||||
process = new BufferedProcess
|
p = new BufferedProcess
|
||||||
command: 'bad-command-nope'
|
command: 'bad-command-nope'
|
||||||
args: ['nothing']
|
args: ['nothing']
|
||||||
options: {}
|
options: {}
|
||||||
|
|
||||||
errorSpy = jasmine.createSpy().andCallFake (error) -> error.handle()
|
errorSpy = jasmine.createSpy().andCallFake (error) -> error.handle()
|
||||||
process.onWillThrowError(errorSpy)
|
p.onWillThrowError(errorSpy)
|
||||||
|
|
||||||
waitsFor -> errorSpy.callCount > 0
|
waitsFor -> errorSpy.callCount > 0
|
||||||
|
|
||||||
|
@ -31,17 +31,17 @@ describe "BufferedProcess", ->
|
||||||
|
|
||||||
describe "when there is not an error handler specified", ->
|
describe "when there is not an error handler specified", ->
|
||||||
it "calls the error handler and does not throw an exception", ->
|
it "calls the error handler and does not throw an exception", ->
|
||||||
process = new BufferedProcess
|
spyOn(process, "nextTick").andCallFake (fn) -> fn()
|
||||||
|
|
||||||
|
try
|
||||||
|
p = new BufferedProcess
|
||||||
command: 'bad-command-nope'
|
command: 'bad-command-nope'
|
||||||
args: ['nothing']
|
args: ['nothing']
|
||||||
options: {}
|
options: {stdout: 'ignore'}
|
||||||
|
|
||||||
waitsFor -> window.onerror.callCount > 0
|
catch error
|
||||||
|
expect(error.message).toContain 'Failed to spawn command `bad-command-nope`'
|
||||||
runs ->
|
expect(error.name).toBe 'BufferedProcessError'
|
||||||
expect(window.onerror).toHaveBeenCalled()
|
|
||||||
expect(window.onerror.mostRecentCall.args[0]).toContain 'Failed to spawn command `bad-command-nope`'
|
|
||||||
expect(window.onerror.mostRecentCall.args[4].name).toBe 'BufferedProcessError'
|
|
||||||
|
|
||||||
describe "on Windows", ->
|
describe "on Windows", ->
|
||||||
originalPlatform = null
|
originalPlatform = null
|
||||||
|
|
|
@ -201,6 +201,7 @@ describe "NylasSyncWorker", ->
|
||||||
expect(@connection.end).toHaveBeenCalled()
|
expect(@connection.end).toHaveBeenCalled()
|
||||||
|
|
||||||
it "should stop trying to restart failed collection syncs", ->
|
it "should stop trying to restart failed collection syncs", ->
|
||||||
|
spyOn(console, 'log')
|
||||||
spyOn(@worker, 'resumeFetches').andCallThrough()
|
spyOn(@worker, 'resumeFetches').andCallThrough()
|
||||||
@worker.cleanup()
|
@worker.cleanup()
|
||||||
advanceClock(50000)
|
advanceClock(50000)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
path = require 'path'
|
||||||
{$, $$} = require '../src/space-pen-extensions'
|
{$, $$} = require '../src/space-pen-extensions'
|
||||||
Package = require '../src/package'
|
Package = require '../src/package'
|
||||||
{Disposable} = require 'atom'
|
{Disposable} = require 'atom'
|
||||||
|
@ -20,11 +21,14 @@ describe "PackageManager", ->
|
||||||
|
|
||||||
it "returns the package if it has an invalid keymap", ->
|
it "returns the package if it has an invalid keymap", ->
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, 'error')
|
||||||
pack = atom.packages.loadPackage("package-with-broken-keymap")
|
pack = atom.packages.loadPackage("package-with-broken-keymap")
|
||||||
expect(pack instanceof Package).toBe true
|
expect(pack instanceof Package).toBe true
|
||||||
expect(pack.metadata.name).toBe "package-with-broken-keymap"
|
expect(pack.metadata.name).toBe "package-with-broken-keymap"
|
||||||
|
|
||||||
it "returns the package if it has an invalid stylesheet", ->
|
it "returns the package if it has an invalid stylesheet", ->
|
||||||
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, 'error')
|
||||||
pack = atom.packages.loadPackage("package-with-invalid-styles")
|
pack = atom.packages.loadPackage("package-with-invalid-styles")
|
||||||
expect(pack instanceof Package).toBe true
|
expect(pack instanceof Package).toBe true
|
||||||
expect(pack.metadata.name).toBe "package-with-invalid-styles"
|
expect(pack.metadata.name).toBe "package-with-invalid-styles"
|
||||||
|
@ -32,12 +36,14 @@ describe "PackageManager", ->
|
||||||
|
|
||||||
it "returns null if the package has an invalid package.json", ->
|
it "returns null if the package has an invalid package.json", ->
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, 'error')
|
||||||
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
|
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
|
||||||
expect(console.warn.callCount).toBe(2)
|
expect(console.warn.callCount).toBe(2)
|
||||||
expect(console.warn.argsForCall[0][0]).toContain("Failed to load package.json")
|
expect(console.warn.argsForCall[0][0]).toContain("Failed to load package.json")
|
||||||
|
|
||||||
it "returns null if the package is not found in any package directory", ->
|
it "returns null if the package is not found in any package directory", ->
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, 'error')
|
||||||
expect(atom.packages.loadPackage("this-package-cannot-be-found")).toBeNull()
|
expect(atom.packages.loadPackage("this-package-cannot-be-found")).toBeNull()
|
||||||
expect(console.warn.callCount).toBe(1)
|
expect(console.warn.callCount).toBe(1)
|
||||||
expect(console.warn.argsForCall[0][0]).toContain("Could not resolve")
|
expect(console.warn.argsForCall[0][0]).toContain("Could not resolve")
|
||||||
|
@ -158,7 +164,7 @@ describe "PackageManager", ->
|
||||||
describe "when the package has no main module", ->
|
describe "when the package has no main module", ->
|
||||||
it "does not throw an exception", ->
|
it "does not throw an exception", ->
|
||||||
spyOn(console, "error")
|
spyOn(console, "error")
|
||||||
spyOn(console, "warn").andCallThrough()
|
spyOn(console, "warn")
|
||||||
expect(-> atom.packages.activatePackage('package-without-module')).not.toThrow()
|
expect(-> atom.packages.activatePackage('package-without-module')).not.toThrow()
|
||||||
expect(console.error).not.toHaveBeenCalled()
|
expect(console.error).not.toHaveBeenCalled()
|
||||||
expect(console.warn).not.toHaveBeenCalled()
|
expect(console.warn).not.toHaveBeenCalled()
|
||||||
|
@ -191,7 +197,9 @@ describe "PackageManager", ->
|
||||||
describe "when the package throws an error while loading", ->
|
describe "when the package throws an error while loading", ->
|
||||||
it "logs a warning instead of throwing an exception", ->
|
it "logs a warning instead of throwing an exception", ->
|
||||||
atom.config.set("core.disabledPackages", [])
|
atom.config.set("core.disabledPackages", [])
|
||||||
|
spyOn(console, "log")
|
||||||
spyOn(console, "warn")
|
spyOn(console, "warn")
|
||||||
|
spyOn(console, "error")
|
||||||
expect(-> atom.packages.activatePackage("package-that-throws-an-exception")).not.toThrow()
|
expect(-> atom.packages.activatePackage("package-that-throws-an-exception")).not.toThrow()
|
||||||
expect(console.warn).toHaveBeenCalled()
|
expect(console.warn).toHaveBeenCalled()
|
||||||
|
|
||||||
|
@ -202,6 +210,7 @@ describe "PackageManager", ->
|
||||||
onSuccess = jasmine.createSpy('onSuccess')
|
onSuccess = jasmine.createSpy('onSuccess')
|
||||||
onFailure = jasmine.createSpy('onFailure')
|
onFailure = jasmine.createSpy('onFailure')
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, "error")
|
||||||
|
|
||||||
atom.packages.activatePackage("this-doesnt-exist").then(onSuccess, onFailure)
|
atom.packages.activatePackage("this-doesnt-exist").then(onSuccess, onFailure)
|
||||||
|
|
||||||
|
@ -433,7 +442,9 @@ describe "PackageManager", ->
|
||||||
expect(pack.mainModule.deactivate).toHaveBeenCalled()
|
expect(pack.mainModule.deactivate).toHaveBeenCalled()
|
||||||
expect(atom.packages.isPackageActive("package-with-module")).toBeFalsy()
|
expect(atom.packages.isPackageActive("package-with-module")).toBeFalsy()
|
||||||
|
|
||||||
|
spyOn(console, 'log')
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, "error")
|
||||||
|
|
||||||
badPack = null
|
badPack = null
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
|
@ -448,7 +459,9 @@ describe "PackageManager", ->
|
||||||
expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeFalsy()
|
expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeFalsy()
|
||||||
|
|
||||||
it "does not serialize packages that have not been activated called on their main module", ->
|
it "does not serialize packages that have not been activated called on their main module", ->
|
||||||
|
spyOn(console, 'log')
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, "error")
|
||||||
badPack = null
|
badPack = null
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.packages.activatePackage("package-that-throws-on-activate").then (p) -> badPack = p
|
atom.packages.activatePackage("package-that-throws-on-activate").then (p) -> badPack = p
|
||||||
|
@ -529,6 +542,7 @@ describe "PackageManager", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
jasmine.snapshotDeprecations()
|
jasmine.snapshotDeprecations()
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, "error")
|
||||||
atom.packages.loadPackages()
|
atom.packages.loadPackages()
|
||||||
|
|
||||||
loadedPackages = atom.packages.getLoadedPackages()
|
loadedPackages = atom.packages.getLoadedPackages()
|
||||||
|
@ -608,6 +622,7 @@ describe "PackageManager", ->
|
||||||
|
|
||||||
it "returns null if the package cannot be loaded", ->
|
it "returns null if the package cannot be loaded", ->
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
|
spyOn(console, "error")
|
||||||
expect(atom.packages.enablePackage("this-doesnt-exist")).toBeNull()
|
expect(atom.packages.enablePackage("this-doesnt-exist")).toBeNull()
|
||||||
expect(console.warn.callCount).toBe 1
|
expect(console.warn.callCount).toBe 1
|
||||||
|
|
||||||
|
@ -615,6 +630,8 @@ describe "PackageManager", ->
|
||||||
didChangeActiveThemesHandler = null
|
didChangeActiveThemesHandler = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
theme_dir = path.resolve(__dirname, '../internal_packages')
|
||||||
|
atom.packages.packageDirPaths.unshift(theme_dir)
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
atom.themes.activateThemes()
|
atom.themes.activateThemes()
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,15 @@ describe "DraftStore", ->
|
||||||
spyOn(DatabaseStore, 'run').andCallFake (query) ->
|
spyOn(DatabaseStore, 'run').andCallFake (query) ->
|
||||||
return Promise.resolve(fakeMessage2) if query._klass is Message
|
return Promise.resolve(fakeMessage2) if query._klass is Message
|
||||||
return Promise.reject(new Error('Not Stubbed'))
|
return Promise.reject(new Error('Not Stubbed'))
|
||||||
spyOn(DatabaseStore, 'persistModel')
|
spyOn(DatabaseStore, 'persistModel').andCallFake -> Promise.resolve()
|
||||||
spyOn(DatabaseStore, 'bindToLocalId')
|
spyOn(DatabaseStore, 'bindToLocalId')
|
||||||
|
|
||||||
|
afterEach ->
|
||||||
|
# Have to cleanup the DraftStoreProxy objects or we'll get a memory
|
||||||
|
# leak error
|
||||||
|
for id, session of DraftStore._draftSessions
|
||||||
|
DraftStore._doneWithSession(session)
|
||||||
|
|
||||||
describe "onComposeReply", ->
|
describe "onComposeReply", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
runs ->
|
runs ->
|
||||||
|
|
|
@ -13,6 +13,11 @@ describe "ThemeManager", ->
|
||||||
configDirPath = atom.getConfigDirPath()
|
configDirPath = atom.getConfigDirPath()
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
spyOn(console, "log")
|
||||||
|
spyOn(console, "warn")
|
||||||
|
spyOn(console, "error")
|
||||||
|
theme_dir = path.resolve(__dirname, '../internal_packages')
|
||||||
|
atom.packages.packageDirPaths.unshift(theme_dir)
|
||||||
themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath})
|
themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath})
|
||||||
|
|
||||||
afterEach ->
|
afterEach ->
|
||||||
|
@ -153,7 +158,6 @@ describe "ThemeManager", ->
|
||||||
|
|
||||||
describe "when a theme fails to load", ->
|
describe "when a theme fails to load", ->
|
||||||
it "logs a warning", ->
|
it "logs a warning", ->
|
||||||
spyOn(console, 'warn')
|
|
||||||
atom.packages.activatePackage('a-theme-that-will-not-be-found')
|
atom.packages.activatePackage('a-theme-that-will-not-be-found')
|
||||||
expect(console.warn.callCount).toBe 1
|
expect(console.warn.callCount).toBe 1
|
||||||
expect(console.warn.argsForCall[0][0]).toContain "Could not resolve 'a-theme-that-will-not-be-found'"
|
expect(console.warn.argsForCall[0][0]).toContain "Could not resolve 'a-theme-that-will-not-be-found'"
|
||||||
|
@ -381,7 +385,6 @@ describe "ThemeManager", ->
|
||||||
themeManager.loadUserStylesheet()
|
themeManager.loadUserStylesheet()
|
||||||
spyOn(themeManager.lessCache, 'cssForFile').andCallFake ->
|
spyOn(themeManager.lessCache, 'cssForFile').andCallFake ->
|
||||||
throw new Error('EACCES permission denied "styles.less"')
|
throw new Error('EACCES permission denied "styles.less"')
|
||||||
spyOn(console, 'error').andCallThrough()
|
|
||||||
|
|
||||||
it "creates an error notification and does not add the stylesheet", ->
|
it "creates an error notification and does not add the stylesheet", ->
|
||||||
themeManager.loadUserStylesheet()
|
themeManager.loadUserStylesheet()
|
||||||
|
@ -397,7 +400,6 @@ describe "ThemeManager", ->
|
||||||
spyOn(File::, 'onDidChange').andCallFake (event) ->
|
spyOn(File::, 'onDidChange').andCallFake (event) ->
|
||||||
throw new Error('Unable to watch path')
|
throw new Error('Unable to watch path')
|
||||||
spyOn(themeManager, 'loadStylesheet').andReturn ''
|
spyOn(themeManager, 'loadStylesheet').andReturn ''
|
||||||
spyOn(console, 'error').andCallThrough()
|
|
||||||
|
|
||||||
it "creates an error notification", ->
|
it "creates an error notification", ->
|
||||||
themeManager.loadUserStylesheet()
|
themeManager.loadUserStylesheet()
|
||||||
|
@ -407,7 +409,6 @@ describe "ThemeManager", ->
|
||||||
|
|
||||||
describe "when a non-existent theme is present in the config", ->
|
describe "when a non-existent theme is present in the config", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
spyOn(console, 'warn')
|
|
||||||
atom.config.set('core.themes', ['non-existent-dark-ui'])
|
atom.config.set('core.themes', ['non-existent-dark-ui'])
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
|
|
|
@ -27,8 +27,6 @@ atom.themes.loadBaseStylesheets()
|
||||||
atom.themes.requireStylesheet '../static/jasmine'
|
atom.themes.requireStylesheet '../static/jasmine'
|
||||||
atom.themes.initialLoadComplete = true
|
atom.themes.initialLoadComplete = true
|
||||||
|
|
||||||
fixturePackagesPath = path.resolve(__dirname, '../spec-nylas/fixtures/packages')
|
|
||||||
atom.packages.packageDirPaths.unshift(fixturePackagesPath)
|
|
||||||
atom.keymaps.loadBundledKeymaps()
|
atom.keymaps.loadBundledKeymaps()
|
||||||
keyBindingsToRestore = atom.keymaps.getKeyBindings()
|
keyBindingsToRestore = atom.keymaps.getKeyBindings()
|
||||||
commandsToRestore = atom.commands.getSnapshot()
|
commandsToRestore = atom.commands.getSnapshot()
|
||||||
|
@ -172,7 +170,20 @@ beforeEach ->
|
||||||
|
|
||||||
addCustomMatchers(this)
|
addCustomMatchers(this)
|
||||||
|
|
||||||
|
|
||||||
|
original_log = console.log
|
||||||
|
original_warn = console.warn
|
||||||
|
original_error = console.error
|
||||||
|
|
||||||
afterEach ->
|
afterEach ->
|
||||||
|
|
||||||
|
if console.log isnt original_log
|
||||||
|
console.log = original_log
|
||||||
|
if console.warn isnt original_warn
|
||||||
|
console.warn = original_warn
|
||||||
|
if console.error isnt original_error
|
||||||
|
console.error = original_error
|
||||||
|
|
||||||
atom.packages.deactivatePackages()
|
atom.packages.deactivatePackages()
|
||||||
atom.menu.template = []
|
atom.menu.template = []
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,8 @@ class Atom extends Model
|
||||||
@actionBridge = new ActionBridge(ipc)
|
@actionBridge = new ActionBridge(ipc)
|
||||||
|
|
||||||
@commands = new CommandRegistry
|
@commands = new CommandRegistry
|
||||||
@packages = new PackageManager({devMode, configDirPath, resourcePath, safeMode})
|
specMode = @inSpecMode()
|
||||||
|
@packages = new PackageManager({devMode, configDirPath, resourcePath, safeMode, specMode})
|
||||||
@styles = new StyleManager
|
@styles = new StyleManager
|
||||||
document.head.appendChild(new StylesElement)
|
document.head.appendChild(new StylesElement)
|
||||||
@themes = new ThemeManager({packageManager: @packages, configDirPath, resourcePath, safeMode})
|
@themes = new ThemeManager({packageManager: @packages, configDirPath, resourcePath, safeMode})
|
||||||
|
@ -229,7 +230,10 @@ class Atom extends Model
|
||||||
# back through the sourcemap as necessary.
|
# back through the sourcemap as necessary.
|
||||||
setupErrorHandling: ->
|
setupErrorHandling: ->
|
||||||
ErrorReporter = require './error-reporter'
|
ErrorReporter = require './error-reporter'
|
||||||
@errorReporter = new ErrorReporter()
|
@errorReporter = new ErrorReporter
|
||||||
|
inSpecMode: @inSpecMode()
|
||||||
|
inDevMode: @inDevMode()
|
||||||
|
|
||||||
sourceMapCache = {}
|
sourceMapCache = {}
|
||||||
|
|
||||||
window.onerror = =>
|
window.onerror = =>
|
||||||
|
|
|
@ -65,7 +65,8 @@ class Application
|
||||||
exit: (status) -> app.exit(status)
|
exit: (status) -> app.exit(status)
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
{@resourcePath, @version, @devMode, @safeMode} = options
|
{@resourcePath, @version, @devMode, test, @safeMode} = options
|
||||||
|
@specMode = test
|
||||||
|
|
||||||
# Normalize to make sure drive letter case is consistent on Windows
|
# Normalize to make sure drive letter case is consistent on Windows
|
||||||
@resourcePath = path.normalize(@resourcePath) if @resourcePath
|
@resourcePath = path.normalize(@resourcePath) if @resourcePath
|
||||||
|
@ -77,7 +78,7 @@ class Application
|
||||||
|
|
||||||
@databases = {}
|
@databases = {}
|
||||||
@windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode})
|
@windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode})
|
||||||
@autoUpdateManager = new AutoUpdateManager(@version, @config)
|
@autoUpdateManager = new AutoUpdateManager(@version, @config, @specMode)
|
||||||
@applicationMenu = new ApplicationMenu(@version)
|
@applicationMenu = new ApplicationMenu(@version)
|
||||||
@nylasProtocolHandler = new NylasProtocolHandler(@resourcePath, @safeMode)
|
@nylasProtocolHandler = new NylasProtocolHandler(@resourcePath, @safeMode)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ module.exports =
|
||||||
class AutoUpdateManager
|
class AutoUpdateManager
|
||||||
_.extend @prototype, EventEmitter.prototype
|
_.extend @prototype, EventEmitter.prototype
|
||||||
|
|
||||||
constructor: (@version, @config) ->
|
constructor: (@version, @config, @specMode) ->
|
||||||
@state = IdleState
|
@state = IdleState
|
||||||
if process.platform is 'win32'
|
if process.platform is 'win32'
|
||||||
# Squirrel for Windows can't handle query params
|
# Squirrel for Windows can't handle query params
|
||||||
|
@ -26,6 +26,7 @@ class AutoUpdateManager
|
||||||
upgradeLevel = @getUpgradeLevel()
|
upgradeLevel = @getUpgradeLevel()
|
||||||
@feedUrl = "https://edgehill.nylas.com/update-check?version=#{@version}&level=#{upgradeLevel}"
|
@feedUrl = "https://edgehill.nylas.com/update-check?version=#{@version}&level=#{upgradeLevel}"
|
||||||
|
|
||||||
|
if not @specMode
|
||||||
process.nextTick => @setupAutoUpdater()
|
process.nextTick => @setupAutoUpdater()
|
||||||
|
|
||||||
getUpgradeLevel: ->
|
getUpgradeLevel: ->
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
global.shellStartTime = Date.now()
|
global.shellStartTime = Date.now()
|
||||||
|
|
||||||
errorReporter = new (require '../error-reporter')
|
|
||||||
|
|
||||||
app = require 'app'
|
app = require 'app'
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
optimist = require 'optimist'
|
optimist = require 'optimist'
|
||||||
|
|
||||||
start = ->
|
start = ->
|
||||||
|
args = parseCommandLine()
|
||||||
|
|
||||||
|
global.errorReporter = setupErrorReporter(args)
|
||||||
|
|
||||||
if process.platform is 'win32'
|
if process.platform is 'win32'
|
||||||
SquirrelUpdate = require './squirrel-update'
|
SquirrelUpdate = require './squirrel-update'
|
||||||
squirrelCommand = process.argv[1]
|
squirrelCommand = process.argv[1]
|
||||||
return if SquirrelUpdate.handleStartupEvent(app, squirrelCommand)
|
return if SquirrelUpdate.handleStartupEvent(app, squirrelCommand)
|
||||||
|
|
||||||
args = parseCommandLine()
|
|
||||||
|
|
||||||
addPathToOpen = (event, pathToOpen) ->
|
addPathToOpen = (event, pathToOpen) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
args.pathsToOpen.push(pathToOpen)
|
args.pathsToOpen.push(pathToOpen)
|
||||||
|
@ -56,10 +56,14 @@ global.devResourcePath = process.env.EDGEHILL_PATH ? process.cwd()
|
||||||
# Normalize to make sure drive letter case is consistent on Windows
|
# Normalize to make sure drive letter case is consistent on Windows
|
||||||
global.devResourcePath = path.normalize(global.devResourcePath) if global.devResourcePath
|
global.devResourcePath = path.normalize(global.devResourcePath) if global.devResourcePath
|
||||||
|
|
||||||
|
setupErrorReporter = (args={}) ->
|
||||||
|
ErrorReporter = require '../error-reporter'
|
||||||
|
return new ErrorReporter({inSpecMode: args.test, inDevMode: args.devMode})
|
||||||
|
|
||||||
setupCrashReporter = ->
|
setupCrashReporter = ->
|
||||||
# In the future, we may want to collect actual native crash reports,
|
# In the future, we may want to collect actual native crash reports,
|
||||||
# but for now let's not send them to github.
|
# but for now let's not send them to GitHub
|
||||||
# crashReporter.start(productName: 'Atom', companyName: 'GitHub')
|
# crashReporter.start(productName: "Nylas Mail", companyName: "Nylas")
|
||||||
|
|
||||||
setupCoffeeScript = ->
|
setupCoffeeScript = ->
|
||||||
CoffeeScript = null
|
CoffeeScript = null
|
||||||
|
|
|
@ -1,35 +1,21 @@
|
||||||
var app, errorReporter, fs, lstatSyncNoException, optimist, parseCommandLine, path, setupCoffeeScript, setupCrashReporter, start, statSyncNoException, _ref;
|
// Generated by CoffeeScript 1.9.2
|
||||||
|
(function() {
|
||||||
|
var app, fs, optimist, parseCommandLine, path, ref, setupCoffeeScript, setupErrorReporter, start;
|
||||||
|
|
||||||
global.shellStartTime = Date.now();
|
global.shellStartTime = Date.now();
|
||||||
|
|
||||||
global.errorReporter = new (require('../error-reporter'));
|
app = require('app');
|
||||||
|
|
||||||
app = require('app');
|
fs = require('fs');
|
||||||
|
|
||||||
fs = require('fs');
|
path = require('path');
|
||||||
|
|
||||||
path = require('path');
|
optimist = require('optimist');
|
||||||
|
|
||||||
optimist = require('optimist');
|
start = function() {
|
||||||
|
|
||||||
lstatSyncNoException = fs.lstatSyncNoException, statSyncNoException = fs.statSyncNoException;
|
|
||||||
|
|
||||||
fs.statSyncNoException = function(pathToStat) {
|
|
||||||
if (!(pathToStat && typeof pathToStat === 'string')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return statSyncNoException(pathToStat);
|
|
||||||
};
|
|
||||||
|
|
||||||
fs.lstatSyncNoException = function(pathToStat) {
|
|
||||||
if (!(pathToStat && typeof pathToStat === 'string')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return lstatSyncNoException(pathToStat);
|
|
||||||
};
|
|
||||||
|
|
||||||
start = function() {
|
|
||||||
var SquirrelUpdate, addPathToOpen, addUrlToOpen, args, squirrelCommand;
|
var SquirrelUpdate, addPathToOpen, addUrlToOpen, args, squirrelCommand;
|
||||||
|
args = parseCommandLine();
|
||||||
|
global.errorReporter = setupErrorReporter(args);
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
SquirrelUpdate = require('./squirrel-update');
|
SquirrelUpdate = require('./squirrel-update');
|
||||||
squirrelCommand = process.argv[1];
|
squirrelCommand = process.argv[1];
|
||||||
|
@ -37,7 +23,6 @@ start = function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args = parseCommandLine();
|
|
||||||
addPathToOpen = function(event, pathToOpen) {
|
addPathToOpen = function(event, pathToOpen) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return args.pathsToOpen.push(pathToOpen);
|
return args.pathsToOpen.push(pathToOpen);
|
||||||
|
@ -49,16 +34,17 @@ start = function() {
|
||||||
};
|
};
|
||||||
app.on('open-file', addPathToOpen);
|
app.on('open-file', addPathToOpen);
|
||||||
app.on('open-url', addUrlToOpen);
|
app.on('open-url', addUrlToOpen);
|
||||||
app.on('will-finish-launching', function() {
|
|
||||||
return setupCrashReporter();
|
|
||||||
});
|
|
||||||
return app.on('ready', function() {
|
return app.on('ready', function() {
|
||||||
var Application;
|
var Application, cwd, ref;
|
||||||
app.removeListener('open-file', addPathToOpen);
|
app.removeListener('open-file', addPathToOpen);
|
||||||
app.removeListener('open-url', addUrlToOpen);
|
app.removeListener('open-url', addUrlToOpen);
|
||||||
|
cwd = ((ref = args.executedFrom) != null ? ref.toString() : void 0) || process.cwd();
|
||||||
args.pathsToOpen = args.pathsToOpen.map(function(pathToOpen) {
|
args.pathsToOpen = args.pathsToOpen.map(function(pathToOpen) {
|
||||||
var _ref;
|
if (cwd) {
|
||||||
return path.resolve((_ref = args.executedFrom) != null ? _ref : process.cwd(), pathToOpen.toString());
|
return path.resolve(cwd, pathToOpen.toString());
|
||||||
|
} else {
|
||||||
|
return path.resolve(pathToOpen.toString());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
setupCoffeeScript();
|
setupCoffeeScript();
|
||||||
if (args.devMode) {
|
if (args.devMode) {
|
||||||
|
@ -72,17 +58,27 @@ start = function() {
|
||||||
return console.log("App load time: " + (Date.now() - global.shellStartTime) + "ms");
|
return console.log("App load time: " + (Date.now() - global.shellStartTime) + "ms");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
global.devResourcePath = (_ref = process.env.EDGEHILL_PATH) != null ? _ref : process.cwd();
|
global.devResourcePath = (ref = process.env.EDGEHILL_PATH) != null ? ref : process.cwd();
|
||||||
|
|
||||||
if (global.devResourcePath) {
|
if (global.devResourcePath) {
|
||||||
global.devResourcePath = path.normalize(global.devResourcePath);
|
global.devResourcePath = path.normalize(global.devResourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupCrashReporter = function() {};
|
setupErrorReporter = function(args) {
|
||||||
|
var ErrorReporter;
|
||||||
|
if (args == null) {
|
||||||
|
args = {};
|
||||||
|
}
|
||||||
|
ErrorReporter = require('../error-reporter');
|
||||||
|
return new ErrorReporter({
|
||||||
|
inSpecMode: args.test,
|
||||||
|
inDevMode: args.devMode
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
setupCoffeeScript = function() {
|
setupCoffeeScript = function() {
|
||||||
var CoffeeScript;
|
var CoffeeScript;
|
||||||
CoffeeScript = null;
|
CoffeeScript = null;
|
||||||
return require.extensions['.coffee'] = function(module, filePath) {
|
return require.extensions['.coffee'] = function(module, filePath) {
|
||||||
|
@ -96,9 +92,9 @@ setupCoffeeScript = function() {
|
||||||
});
|
});
|
||||||
return module._compile(js, filePath);
|
return module._compile(js, filePath);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
parseCommandLine = function() {
|
parseCommandLine = function() {
|
||||||
var args, devMode, executedFrom, logFile, newWindow, options, packageDirectoryPath, packageManifest, packageManifestPath, pathsToOpen, pidToKillWhenClosed, resourcePath, safeMode, specDirectory, specFilePattern, test, version;
|
var args, devMode, executedFrom, logFile, newWindow, options, packageDirectoryPath, packageManifest, packageManifestPath, pathsToOpen, pidToKillWhenClosed, resourcePath, safeMode, specDirectory, specFilePattern, test, version;
|
||||||
version = app.getVersion();
|
version = app.getVersion();
|
||||||
options = optimist(process.argv.slice(1));
|
options = optimist(process.argv.slice(1));
|
||||||
|
@ -120,7 +116,7 @@ parseCommandLine = function() {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
if (args.version) {
|
if (args.version) {
|
||||||
process.stdout.write("" + version + "\n");
|
process.stdout.write(version + "\n");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
executedFrom = args['executed-from'];
|
executedFrom = args['executed-from'];
|
||||||
|
@ -188,6 +184,8 @@ parseCommandLine = function() {
|
||||||
logFile: logFile,
|
logFile: logFile,
|
||||||
specFilePattern: specFilePattern
|
specFilePattern: specFilePattern
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
|
@ -24,9 +24,25 @@ var logpath = path.join(tmpPath, 'edgehill-' + logpid + '.log');
|
||||||
|
|
||||||
|
|
||||||
module.exports = ErrorReporter = (function() {
|
module.exports = ErrorReporter = (function() {
|
||||||
function ErrorReporter() {
|
|
||||||
|
function ErrorReporter(modes) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
this.inSpecMode = modes.inSpecMode
|
||||||
|
this.inDevMode = modes.inDevMode
|
||||||
|
|
||||||
|
if (!this.inSpecMode) {
|
||||||
|
this._setupSentry();
|
||||||
|
this._cleanOldLogFiles();
|
||||||
|
this._setupNewLogFile();
|
||||||
|
this._hookProcessOutputs();
|
||||||
|
this._catchUncaughtErrors();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.debug = _.bind(this.consoleDebug, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorReporter.prototype._setupSentry = function() {
|
||||||
// Initialize the Sentry connector
|
// Initialize the Sentry connector
|
||||||
this.client = new raven.Client('https://7a32cb0189ff4595a55c98ffb7939c46:f791c3c402b343068bed056b8b504dd5@sentry.nylas.com/4');
|
this.client = new raven.Client('https://7a32cb0189ff4595a55c98ffb7939c46:f791c3c402b343068bed056b8b504dd5@sentry.nylas.com/4');
|
||||||
this.client.on('error', function(e) {
|
this.client.on('error', function(e) {
|
||||||
|
@ -34,10 +50,12 @@ module.exports = ErrorReporter = (function() {
|
||||||
console.log(e.statusCode);
|
console.log(e.statusCode);
|
||||||
return console.log(e.response);
|
return console.log(e.response);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// If we're the browser process, remove log files that are more than
|
// If we're the browser process, remove log files that are more than
|
||||||
// two days old. These log files get pretty big because we're logging
|
// two days old. These log files get pretty big because we're logging
|
||||||
// so verbosely.
|
// so verbosely.
|
||||||
|
ErrorReporter.prototype._cleanOldLogFiles = function() {
|
||||||
if (process.type === 'browser') {
|
if (process.type === 'browser') {
|
||||||
fs.readdir(tmpPath, function(err, files) {
|
fs.readdir(tmpPath, function(err, files) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -60,6 +78,11 @@ module.exports = ErrorReporter = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorReporter.prototype._setupNewLogFile = function() {
|
||||||
|
this.shipLogsQueued = false;
|
||||||
|
this.shipLogsTime = 0;
|
||||||
|
|
||||||
// Open a file write stream to log output from this process
|
// Open a file write stream to log output from this process
|
||||||
console.log("Streaming log data to "+logpath);
|
console.log("Streaming log data to "+logpath);
|
||||||
|
@ -71,7 +94,10 @@ module.exports = ErrorReporter = (function() {
|
||||||
fd: null,
|
fd: null,
|
||||||
mode: 0666
|
mode: 0666
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorReporter.prototype._hookProcessOutputs = function() {
|
||||||
|
var self = this;
|
||||||
// Override stdout and stderr to pipe their output to the file
|
// Override stdout and stderr to pipe their output to the file
|
||||||
// in addition to calling through to the existing implementation
|
// in addition to calling through to the existing implementation
|
||||||
function hook_process_output(channel, callback) {
|
function hook_process_output(channel, callback) {
|
||||||
|
@ -95,32 +121,13 @@ module.exports = ErrorReporter = (function() {
|
||||||
hook_process_output('stderr', function(string, encoding, fd) {
|
hook_process_output('stderr', function(string, encoding, fd) {
|
||||||
self.appendLog.apply(self, [string]);
|
self.appendLog.apply(self, [string]);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.shipLogsQueued = false;
|
|
||||||
this.shipLogsTime = 0;
|
|
||||||
|
|
||||||
// Create a new console.debug option, which takes `true` (print)
|
|
||||||
// or `false`, don't print in console as the first parameter.
|
|
||||||
// This makes it easy for developers to turn on and off
|
|
||||||
// "verbose console" mode.
|
|
||||||
console.debug = function() {
|
|
||||||
var args = [];
|
|
||||||
var showIt = arguments[0];
|
|
||||||
for (var ii = 1; ii < arguments.length; ii++) {
|
|
||||||
args.push(arguments[ii]);
|
|
||||||
}
|
}
|
||||||
if ((self.dev === true) && (showIt === true)) {
|
|
||||||
console.log.apply(this, args);
|
|
||||||
}
|
|
||||||
self.appendLog.apply(self, [args]);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
ErrorReporter.prototype._catchUncaughtErrors = function() {
|
||||||
|
var self = this;
|
||||||
// Link to the appropriate error handlers for the browser
|
// Link to the appropriate error handlers for the browser
|
||||||
// or renderer process
|
// or renderer process
|
||||||
if (process.type === 'renderer') {
|
if (process.type === 'renderer') {
|
||||||
this.spec = atom.inSpecMode();
|
|
||||||
this.dev = atom.inDevMode();
|
|
||||||
|
|
||||||
atom.onDidThrowError(function(_arg) {
|
atom.onDidThrowError(function(_arg) {
|
||||||
return self.reportError(_arg.originalError, {
|
return self.reportError(_arg.originalError, {
|
||||||
'message': _arg.message
|
'message': _arg.message
|
||||||
|
@ -146,7 +153,25 @@ module.exports = ErrorReporter = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new console.debug option, which takes `true` (print)
|
||||||
|
// or `false`, don't print in console as the first parameter.
|
||||||
|
// This makes it easy for developers to turn on and off
|
||||||
|
// "verbose console" mode.
|
||||||
|
ErrorReporter.prototype.consoleDebug = function() {
|
||||||
|
var args = [];
|
||||||
|
var showIt = arguments[0];
|
||||||
|
for (var ii = 1; ii < arguments.length; ii++) {
|
||||||
|
args.push(arguments[ii]);
|
||||||
|
}
|
||||||
|
if ((this.dev === true) && (showIt === true)) {
|
||||||
|
console.log.apply(this, args);
|
||||||
|
}
|
||||||
|
this.appendLog.apply(this, [args]);
|
||||||
|
}
|
||||||
|
|
||||||
ErrorReporter.prototype.appendLog = function(obj) {
|
ErrorReporter.prototype.appendLog = function(obj) {
|
||||||
|
if (this.inSpecMode) { return };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var message = JSON.stringify({
|
var message = JSON.stringify({
|
||||||
host: this.loghost,
|
host: this.loghost,
|
||||||
|
@ -170,6 +195,8 @@ module.exports = ErrorReporter = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorReporter.prototype.shipLogs = function(reason) {
|
ErrorReporter.prototype.shipLogs = function(reason) {
|
||||||
|
if (this.inSpecMode) { return };
|
||||||
|
|
||||||
if (!this.shipLogsQueued) {
|
if (!this.shipLogsQueued) {
|
||||||
var timeSinceLogShip = Date.now() - this.shipLogsTime;
|
var timeSinceLogShip = Date.now() - this.shipLogsTime;
|
||||||
if (timeSinceLogShip > 20000) {
|
if (timeSinceLogShip > 20000) {
|
||||||
|
@ -186,6 +213,8 @@ module.exports = ErrorReporter = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorReporter.prototype.runShipLogsTask = function(reason) {
|
ErrorReporter.prototype.runShipLogsTask = function(reason) {
|
||||||
|
if (this.inSpecMode) { return };
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.shipLogsTime = Date.now();
|
this.shipLogsTime = Date.now();
|
||||||
|
@ -216,12 +245,7 @@ module.exports = ErrorReporter = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorReporter.prototype.reportError = function(err, metadata) {
|
ErrorReporter.prototype.reportError = function(err, metadata) {
|
||||||
if (this.spec) {
|
if (this.inSpecMode || this.inDevMode) { return };
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.dev) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client.captureError(err, {
|
this.client.captureError(err, {
|
||||||
extra: metadata,
|
extra: metadata,
|
||||||
|
|
|
@ -32,14 +32,17 @@ module.exports =
|
||||||
class PackageManager
|
class PackageManager
|
||||||
EmitterMixin.includeInto(this)
|
EmitterMixin.includeInto(this)
|
||||||
|
|
||||||
constructor: ({configDirPath, @devMode, safeMode, @resourcePath}) ->
|
constructor: ({configDirPath, @devMode, safeMode, @resourcePath, @specMode}) ->
|
||||||
@emitter = new Emitter
|
@emitter = new Emitter
|
||||||
@packageDirPaths = []
|
@packageDirPaths = []
|
||||||
unless safeMode
|
if @specMode
|
||||||
|
@packageDirPaths.push(path.join(@resourcePath, "spec-nylas", "fixtures", "packages"))
|
||||||
|
else
|
||||||
|
@packageDirPaths.push(path.join(@resourcePath, "internal_packages"))
|
||||||
|
if not safeMode
|
||||||
if @devMode
|
if @devMode
|
||||||
@packageDirPaths.push(path.join(configDirPath, "dev", "packages"))
|
@packageDirPaths.push(path.join(configDirPath, "dev", "packages"))
|
||||||
@packageDirPaths.push(path.join(configDirPath, "packages"))
|
@packageDirPaths.push(path.join(configDirPath, "packages"))
|
||||||
@packageDirPaths.push(path.join(@resourcePath, "internal_packages"))
|
|
||||||
|
|
||||||
@loadedPackages = {}
|
@loadedPackages = {}
|
||||||
@activePackages = {}
|
@activePackages = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue