forked from atom/atom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathless-compile-cache.coffee
33 lines (26 loc) · 996 Bytes
/
less-compile-cache.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
path = require 'path'
LessCache = require 'less-cache'
# {LessCache} wrapper used by {ThemeManager} to read stylesheets.
module.exports =
class LessCompileCache
@cacheDir: path.join(process.env.ATOM_HOME, 'compile-cache', 'less')
constructor: ({resourcePath, importPaths}) ->
@lessSearchPaths = [
path.join(resourcePath, 'static', 'variables')
path.join(resourcePath, 'static')
]
if importPaths?
importPaths = importPaths.concat(@lessSearchPaths)
else
importPaths = @lessSearchPaths
@cache = new LessCache
cacheDir: @constructor.cacheDir
importPaths: importPaths
resourcePath: resourcePath
fallbackDir: path.join(resourcePath, 'less-compile-cache')
setImportPaths: (importPaths=[]) ->
@cache.setImportPaths(importPaths.concat(@lessSearchPaths))
read: (stylesheetPath) ->
@cache.readFileSync(stylesheetPath)
cssForFile: (stylesheetPath, lessContent) ->
@cache.cssForFile(stylesheetPath, lessContent)