💉 resource path into LessCompileCache

This commit is contained in:
Kevin Sawicki
2013-11-11 09:20:48 -08:00
parent a377a49004
commit 78617e31bc
5 changed files with 14 additions and 11 deletions

View File

@@ -8,7 +8,9 @@ describe "ThemeManager", ->
themeManager = null
beforeEach ->
themeManager = new ThemeManager(atom.packages)
themeManager = new ThemeManager
packageManager: atom.packages
resourcePath: window.resourcePath
afterEach ->
themeManager.deactivateThemes()

View File

@@ -62,7 +62,7 @@ class Atom
@packages = new PackageManager({devMode, configDirPath, resourcePath})
@subscribe @packages, 'activated', => @watchThemes()
@themes = new ThemeManager(@packages)
@themes = new ThemeManager({packageManager: @packages, @resourcePath})
@contextMenu = new ContextMenuManager(devMode)
@menu = new MenuManager()
@pasteboard = new Pasteboard()

View File

@@ -37,10 +37,6 @@ class Config
@bundledMenusDirPath = path.join(resourcePath, "menus")
@nodeModulesDirPath = path.join(@resourcePath, "node_modules")
@bundledPackageDirPaths = [@nodeModulesDirPath]
@lessSearchPaths = [
path.join(@resourcePath, 'static', 'variables')
path.join(@resourcePath, 'static')
]
@packageDirPaths = [path.join(@configDirPath, "packages")]
if atom.getLoadSettings().devMode
@packageDirPaths.unshift(path.join(@configDirPath, "dev", "packages"))

View File

@@ -11,16 +11,21 @@ class LessCompileCache
@cacheDir: path.join(tmpDir, 'atom-compile-cache', 'less')
constructor: ->
constructor: ({resourcePath})->
@cache = new LessCache
cacheDir: @constructor.cacheDir
importPaths: @getImportPaths()
resourcePath: window.resourcePath
fallbackDir: path.join(window.resourcePath, 'less-compile-cache')
fallbackDir: path.join(resourcePath, 'less-compile-cache')
@lessSearchPaths = [
path.join(resourcePath, 'static', 'variables')
path.join(resourcePath, 'static')
]
@subscribe atom.themes, 'reloaded', => @cache.setImportPaths(@getImportPaths())
getImportPaths: -> atom.themes.getImportPaths().concat(atom.config.lessSearchPaths)
getImportPaths: -> atom.themes.getImportPaths().concat(@lessSearchPaths)
read: (stylesheetPath) -> @cache.readFileSync(stylesheetPath)

View File

@@ -17,7 +17,7 @@ module.exports =
class ThemeManager
Emitter.includeInto(this)
constructor: (@packageManager) ->
constructor: ({@packageManager, @resourcePath}) ->
@lessCache = null
@packageManager.registerPackageActivator(this, ['theme'])
@@ -148,7 +148,7 @@ class ThemeManager
loadLessStylesheet: (lessStylesheetPath) ->
unless lessCache?
LessCompileCache = require './less-compile-cache'
@lessCache = new LessCompileCache()
@lessCache = new LessCompileCache({@resourcePath})
try
@lessCache.read(lessStylesheetPath)