mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Load packages with the fallback variables
This commit is contained in:
@@ -158,7 +158,7 @@ class Package
|
||||
|
||||
loadStylesheets: ->
|
||||
@stylesheets = @getStylesheetPaths().map (stylesheetPath) ->
|
||||
[stylesheetPath, atom.themes.loadStylesheet(stylesheetPath)]
|
||||
[stylesheetPath, atom.themes.loadStylesheet(stylesheetPath, true)]
|
||||
|
||||
getStylesheetsPath: ->
|
||||
path.join(@path, @constructor.stylesheetsDir)
|
||||
|
||||
@@ -167,22 +167,30 @@ class ThemeManager
|
||||
|
||||
fullPath
|
||||
|
||||
loadStylesheet: (stylesheetPath) ->
|
||||
loadStylesheet: (stylesheetPath, importFallbackVariables) ->
|
||||
if path.extname(stylesheetPath) is '.less'
|
||||
@loadLessStylesheet(stylesheetPath)
|
||||
@loadLessStylesheet(stylesheetPath, importFallbackVariables)
|
||||
else
|
||||
fs.readFileSync(stylesheetPath, 'utf8')
|
||||
|
||||
loadLessStylesheet: (lessStylesheetPath) ->
|
||||
loadLessStylesheet: (lessStylesheetPath, importFallbackVariables=false) ->
|
||||
unless @lessCache?
|
||||
LessCompileCache = require './less-compile-cache'
|
||||
@lessCache = new LessCompileCache({@resourcePath, importPaths: @getImportPaths()})
|
||||
|
||||
try
|
||||
@lessCache.read(lessStylesheetPath)
|
||||
if importFallbackVariables
|
||||
baseVarImports = """
|
||||
@import "#{path.join(@resourcePath, 'static', 'variables', 'ui-variables')}";
|
||||
@import "#{path.join(@resourcePath, 'static', 'variables', 'syntax-variables')}";
|
||||
"""
|
||||
less = fs.readFileSync(lessStylesheetPath, 'utf8')
|
||||
@lessCache.cssForFile(lessStylesheetPath, [baseVarImports, less].join('\n'))
|
||||
else
|
||||
@lessCache.read(lessStylesheetPath)
|
||||
catch e
|
||||
console.error """
|
||||
Error compiling less stylesheet: #{lessStylesheetPath}
|
||||
Error compiling less stylesheet: #{importFallbackVariables} #{lessStylesheetPath}
|
||||
Line number: #{e.line}
|
||||
#{e.message}
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user