Skip to content

Commit b2ef8ab

Browse files
author
Antonio Scandurra
committed
Don't use cached less sources and imported files in dev mode
1 parent 684d8bd commit b2ef8ab

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/atom-environment.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class AtomEnvironment extends Model
232232

233233
@styles.initialize({@configDirPath})
234234
@packages.initialize({devMode, @configDirPath, resourcePath, safeMode})
235-
@themes.initialize({@configDirPath, resourcePath, safeMode})
235+
@themes.initialize({@configDirPath, resourcePath, safeMode, devMode})
236236

237237
@commandInstaller.initialize(@getVersion())
238238
@workspace.initialize()

src/less-compile-cache.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ LessCache = require 'less-cache'
44
# {LessCache} wrapper used by {ThemeManager} to read stylesheets.
55
module.exports =
66
class LessCompileCache
7-
@cacheDir: path.join(process.env.ATOM_HOME, 'compile-cache', 'less')
8-
97
constructor: ({resourcePath, importPaths, lessSourcesByRelativeFilePath, importedFilePathsByRelativeImportPath}) ->
8+
cacheDir = path.join(process.env.ATOM_HOME, 'compile-cache', 'less')
9+
1010
@lessSearchPaths = [
1111
path.join(resourcePath, 'static', 'variables')
1212
path.join(resourcePath, 'static')
@@ -22,7 +22,7 @@ class LessCompileCache
2222
resourcePath,
2323
lessSourcesByRelativeFilePath,
2424
importedFilePathsByRelativeImportPath,
25-
cacheDir: @constructor.cacheDir,
25+
cacheDir,
2626
fallbackDir: path.join(resourcePath, 'less-compile-cache')
2727
})
2828

src/theme-manager.coffee

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ _ = require 'underscore-plus'
33
{Emitter, CompositeDisposable} = require 'event-kit'
44
{File} = require 'pathwatcher'
55
fs = require 'fs-plus'
6+
LessCompileCache = require './less-compile-cache'
67

78
# Extended: Handles loading and activating available themes.
89
#
@@ -18,16 +19,15 @@ class ThemeManager
1819
@packageManager.onDidActivateInitialPackages =>
1920
@onDidChangeActiveThemes => @packageManager.reloadActivePackageStyleSheets()
2021

22+
initialize: ({@resourcePath, @configDirPath, @safeMode, devMode}) ->
2123
@lessSourcesByRelativeFilePath = null
22-
if typeof snapshotAuxiliaryData is 'undefined'
24+
if devMode or typeof snapshotAuxiliaryData is 'undefined'
2325
@lessSourcesByRelativeFilePath = {}
2426
@importedFilePathsByRelativeImportPath = {}
2527
else
2628
@lessSourcesByRelativeFilePath = snapshotAuxiliaryData.lessSourcesByRelativeFilePath
2729
@importedFilePathsByRelativeImportPath = snapshotAuxiliaryData.importedFilePathsByRelativeImportPath
2830

29-
initialize: ({@resourcePath, @configDirPath, @safeMode}) ->
30-
3131
###
3232
Section: Event Subscription
3333
###
@@ -202,14 +202,12 @@ class ThemeManager
202202
fs.readFileSync(stylesheetPath, 'utf8')
203203

204204
loadLessStylesheet: (lessStylesheetPath, importFallbackVariables=false) ->
205-
unless @lessCache?
206-
LessCompileCache = require './less-compile-cache'
207-
@lessCache = new LessCompileCache({
208-
@resourcePath,
209-
@lessSourcesByRelativeFilePath,
210-
@importedFilePathsByRelativeImportPath,
211-
importPaths: @getImportPaths()
212-
})
205+
@lessCache ?= new LessCompileCache({
206+
@resourcePath,
207+
@lessSourcesByRelativeFilePath,
208+
@importedFilePathsByRelativeImportPath,
209+
importPaths: @getImportPaths()
210+
})
213211

214212
try
215213
if importFallbackVariables

0 commit comments

Comments
 (0)