From bbe02fc6b005a89e6d987a5a1a8caaf1da85e060 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Fri, 11 Jul 2014 14:07:19 -0700 Subject: [PATCH] Load packages with the fallback variables --- src/package.coffee | 2 +- src/theme-manager.coffee | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/package.coffee b/src/package.coffee index 3ccd2d614..53921a609 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -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) diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index 6ec9bd282..c9419987e 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -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} """