mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Get the proper directories before themeManage load
This commit is contained in:
@@ -12,6 +12,28 @@ describe "ThemeManager", ->
|
||||
afterEach ->
|
||||
themeManager.unload()
|
||||
|
||||
describe "getImportPaths()", ->
|
||||
it "returns the theme directories before the themes are loaded", ->
|
||||
config.set('core.themes', ['atom-dark-syntax', 'atom-dark-ui', 'atom-light-ui'])
|
||||
|
||||
paths = themeManager.getImportPaths()
|
||||
|
||||
# syntax theme is not a dir at this time, so only two.
|
||||
expect(paths.length).toBe 2
|
||||
expect(paths[0]).toContain 'atom-dark-ui'
|
||||
expect(paths[1]).toContain 'atom-light-ui'
|
||||
|
||||
it "returns the theme directories before the themes are loaded", ->
|
||||
config.set('core.themes', ['atom-dark-syntax', 'atom-dark-ui', 'atom-light-ui'])
|
||||
themeManager.load()
|
||||
|
||||
paths = themeManager.getImportPaths()
|
||||
|
||||
# syntax theme is not a dir at this time, so only two.
|
||||
expect(paths.length).toBe 2
|
||||
expect(paths[0]).toContain 'atom-dark-ui'
|
||||
expect(paths[1]).toContain 'atom-light-ui'
|
||||
|
||||
describe "when the core.themes config value changes", ->
|
||||
it "add/removes stylesheets to reflect the new config value", ->
|
||||
themeManager.on 'reloaded', reloadHandler = jasmine.createSpy()
|
||||
|
||||
@@ -50,7 +50,15 @@ class ThemeManager
|
||||
null
|
||||
|
||||
getImportPaths: ->
|
||||
theme.directoryPath for theme in @loadedThemes when theme.directoryPath
|
||||
if @loadedThemes.length
|
||||
theme.directoryPath for theme in @loadedThemes when theme.directoryPath
|
||||
else
|
||||
themeNames = config.get('core.themes')
|
||||
themes = []
|
||||
for themeName in themeNames
|
||||
themePath = Theme.resolve(themeName)
|
||||
themes.push(themePath) if fsUtils.isDirectorySync(themePath)
|
||||
themes
|
||||
|
||||
loadUserStylesheet: ->
|
||||
if userStylesheetPath = @getUserStylesheetPath()
|
||||
|
||||
@@ -8,12 +8,15 @@ class Theme
|
||||
stylesheetPath: null
|
||||
stylesheets: null
|
||||
|
||||
@resolve: (themeName) ->
|
||||
if fsUtils.exists(themeName)
|
||||
themeName
|
||||
else
|
||||
fsUtils.resolve(config.themeDirPaths..., themeName, ['', '.css', 'less'])
|
||||
|
||||
constructor: (name) ->
|
||||
@stylesheets = []
|
||||
if fsUtils.exists(name)
|
||||
@stylesheetPath = name
|
||||
else
|
||||
@stylesheetPath = fsUtils.resolve(config.themeDirPaths..., name, ['', '.css', 'less'])
|
||||
@stylesheetPath = Theme.resolve(name)
|
||||
|
||||
throw new Error("No theme exists named '#{name}'") unless @stylesheetPath
|
||||
|
||||
|
||||
Reference in New Issue
Block a user