Log warning when enabled theme isn't installed

This commit is contained in:
Kevin Sawicki
2014-02-20 11:41:23 -08:00
parent ff519d52b2
commit 08ede33b66
2 changed files with 19 additions and 1 deletions

View File

@@ -224,3 +224,14 @@ describe "ThemeManager", ->
runs ->
expect($(document.body).css('border-style')).toBe 'none'
describe "when a non-existent theme is present in the config", ->
it "logs a warning but does not throw an exception (regression)", ->
waitsForPromise ->
themeManager.activateThemes()
runs ->
spyOn(console, 'warn')
expect(-> atom.config.set('core.themes', ['atom-light-ui', 'theme-really-does-not-exist'])).not.toThrow()
expect(console.warn.callCount).toBe 1
expect(console.warn.argsForCall[0][0].length).toBeGreaterThan 0

View File

@@ -61,7 +61,14 @@ class ThemeManager
@deactivateThemes()
@refreshLessCache() # Update cache for packages in core.themes config
promises = @getEnabledThemeNames().map (themeName) => @packageManager.activatePackage(themeName)
promises = []
for themeName in @getEnabledThemeNames()
if @packageManager.resolvePackagePath(themeName)
promises.push(@packageManager.activatePackage(themeName))
else
console.warn("Failed to activate theme '#{themeName}' because it isn't installed.")
Q.all(promises).then =>
@refreshLessCache() # Update cache again now that @getActiveThemes() is populated
@loadUserStylesheet()