Re-throw stylesheet compile errors
This makes it consistent with other read errors. Previously a Notification was returned in the error case causing errors downstream where the package's stylesheets array was assumed to be a path/content tuple. Closes atom/deprecation-cop#22
Esse commit está contido em:
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"name": "package-with-invalid-styles",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{
|
||||||
@@ -23,6 +23,12 @@ describe "PackageManager", ->
|
|||||||
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", ->
|
||||||
|
pack = atom.packages.loadPackage("package-with-invalid-styles")
|
||||||
|
expect(pack instanceof Package).toBe true
|
||||||
|
expect(pack.metadata.name).toBe "package-with-invalid-styles"
|
||||||
|
expect(pack.stylesheets.length).toBe 0
|
||||||
|
|
||||||
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')
|
||||||
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
|
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
|
||||||
|
|||||||
@@ -364,12 +364,13 @@ describe "ThemeManager", ->
|
|||||||
throw new Error('EACCES permission denied "styles.less"')
|
throw new Error('EACCES permission denied "styles.less"')
|
||||||
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
|
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
|
||||||
|
|
||||||
it "creates an error notification", ->
|
it "creates an error notification and does not add the stylesheet", ->
|
||||||
themeManager.loadUserStylesheet()
|
themeManager.loadUserStylesheet()
|
||||||
expect(addErrorHandler).toHaveBeenCalled()
|
expect(addErrorHandler).toHaveBeenCalled()
|
||||||
note = addErrorHandler.mostRecentCall.args[0]
|
note = addErrorHandler.mostRecentCall.args[0]
|
||||||
expect(note.getType()).toBe 'error'
|
expect(note.getType()).toBe 'error'
|
||||||
expect(note.getMessage()).toContain 'Error loading'
|
expect(note.getMessage()).toContain 'Error loading'
|
||||||
|
expect(atom.styles.styleElementsBySourcePath[atom.styles.getUserStyleSheetPath()]).toBeUndefined()
|
||||||
|
|
||||||
describe "when there is an error watching the user stylesheet", ->
|
describe "when there is an error watching the user stylesheet", ->
|
||||||
addErrorHandler = null
|
addErrorHandler = null
|
||||||
|
|||||||
@@ -266,7 +266,11 @@ class ThemeManager
|
|||||||
"""
|
"""
|
||||||
atom.notifications.addError(message, dismissable: true)
|
atom.notifications.addError(message, dismissable: true)
|
||||||
|
|
||||||
userStylesheetContents = @loadStylesheet(userStylesheetPath, true)
|
try
|
||||||
|
userStylesheetContents = @loadStylesheet(userStylesheetPath, true)
|
||||||
|
catch
|
||||||
|
return
|
||||||
|
|
||||||
@userStyleSheetDisposable = atom.styles.addStyleSheet(userStylesheetContents, sourcePath: userStylesheetPath, priority: 2)
|
@userStyleSheetDisposable = atom.styles.addStyleSheet(userStylesheetContents, sourcePath: userStylesheetPath, priority: 2)
|
||||||
|
|
||||||
loadBaseStylesheets: ->
|
loadBaseStylesheets: ->
|
||||||
@@ -320,6 +324,7 @@ class ThemeManager
|
|||||||
detail = error.message
|
detail = error.message
|
||||||
|
|
||||||
atom.notifications.addError(message, {detail, dismissable: true})
|
atom.notifications.addError(message, {detail, dismissable: true})
|
||||||
|
throw error
|
||||||
|
|
||||||
removeStylesheet: (stylesheetPath) ->
|
removeStylesheet: (stylesheetPath) ->
|
||||||
@styleSheetDisposablesBySourcePath[stylesheetPath]?.dispose()
|
@styleSheetDisposablesBySourcePath[stylesheetPath]?.dispose()
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário