diff --git a/.travis.yml b/.travis.yml index 3ce84c266..b947b0f9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ script: script/cibuild cache: directories: - node_modules + - $HOME/.atom/compile-cache notifications: email: diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 80bc37688..ebaf1642d 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -121,6 +121,8 @@ module.exports = (grunt) -> ext: '.css' prebuildLessConfig = + options: + cachePath: path.join(homeDir, '.atom', 'compile-cache', 'prebuild-less', require('less-cache/package.json').version) src: [ 'static/**/*.less' ] diff --git a/build/tasks/prebuild-less-task.coffee b/build/tasks/prebuild-less-task.coffee index 3704fffdc..d5b1fae2c 100644 --- a/build/tasks/prebuild-less-task.coffee +++ b/build/tasks/prebuild-less-task.coffee @@ -5,6 +5,8 @@ LessCache = require 'less-cache' module.exports = (grunt) -> {rm} = require('./task-helpers')(grunt) + cacheMisses = 0 + cacheHits = 0 compileBootstrap = -> appDir = grunt.config.get('atom.appDir') @@ -13,12 +15,16 @@ module.exports = (grunt) -> lessCache = new LessCache cacheDir: temp.mkdirSync('atom-less-cache') + fallbackDir: grunt.config.get('prebuild-less.options.cachePath') + syncCaches: true resourcePath: path.resolve('.') bootstrapCss = lessCache.readFileSync(bootstrapLessPath) grunt.file.write(bootstrapCssPath, bootstrapCss) rm(bootstrapLessPath) rm(path.join(appDir, 'node_modules', 'bootstrap', 'less')) + cacheMisses += lessCache.stats.misses + cacheHits += lessCache.stats.hits importFallbackVariables = (lessFilePath) -> if lessFilePath.indexOf('static') is 0 @@ -29,40 +35,28 @@ module.exports = (grunt) -> grunt.registerMultiTask 'prebuild-less', 'Prebuild cached of compiled Less files', -> compileBootstrap() - prebuiltConfigurations = [ - ['atom-dark-ui', 'atom-dark-syntax'] - ['atom-dark-ui', 'atom-light-syntax'] - ['atom-dark-ui', 'one-dark-syntax'] - ['atom-dark-ui', 'one-light-syntax'] - ['atom-dark-ui', 'solarized-dark-syntax'] - ['atom-dark-ui', 'base16-tomorrow-dark-theme'] - ['atom-dark-ui', 'base16-tomorrow-light-theme'] - - ['atom-light-ui', 'atom-light-syntax'] - ['atom-light-ui', 'atom-dark-syntax'] - ['atom-light-ui', 'one-dark-syntax'] - ['atom-light-ui', 'one-light-syntax'] - ['atom-light-ui', 'solarized-dark-syntax'] - ['atom-light-ui', 'base16-tomorrow-dark-theme'] - ['atom-light-ui', 'base16-tomorrow-light-theme'] - - ['one-dark-ui', 'one-dark-syntax'] - ['one-dark-ui', 'one-light-syntax'] - ['one-dark-ui', 'atom-dark-syntax'] - ['one-dark-ui', 'atom-light-syntax'] - ['one-dark-ui', 'solarized-dark-syntax'] - ['one-dark-ui', 'base16-tomorrow-dark-theme'] - ['one-dark-ui', 'base16-tomorrow-light-theme'] - - ['one-light-ui', 'one-light-syntax'] - ['one-light-ui', 'one-dark-syntax'] - ['one-light-ui', 'atom-light-syntax'] - ['one-light-ui', 'atom-dark-syntax'] - ['one-light-ui', 'solarized-dark-syntax'] - ['one-light-ui', 'base16-tomorrow-dark-theme'] - ['one-light-ui', 'base16-tomorrow-light-theme'] + uiThemes = [ + 'atom-dark-ui' + 'atom-light-ui' + 'one-dark-ui' + 'one-light-ui' ] + syntaxThemes = [ + 'atom-dark-syntax' + 'atom-light-syntax' + 'one-dark-syntax' + 'one-light-syntax' + 'solarized-dark-syntax' + 'base16-tomorrow-dark-theme' + 'base16-tomorrow-light-theme' + ] + + prebuiltConfigurations = [] + uiThemes.forEach (uiTheme) -> + syntaxThemes.forEach (syntaxTheme) -> + prebuiltConfigurations.push([uiTheme, syntaxTheme]) + directory = path.join(grunt.config.get('atom.appDir'), 'less-compile-cache') for configuration in prebuiltConfigurations @@ -84,6 +78,8 @@ module.exports = (grunt) -> grunt.verbose.writeln("Building Less cache for #{configuration.join(', ').yellow}") lessCache = new LessCache cacheDir: directory + fallbackDir: grunt.config.get('prebuild-less.options.cachePath') + syncCaches: true resourcePath: path.resolve('.') importPaths: importPaths @@ -104,3 +100,8 @@ module.exports = (grunt) -> for file in themeMains grunt.verbose.writeln("File #{file.cyan} created in cache.") cssForFile(file) + + cacheMisses += lessCache.stats.misses + cacheHits += lessCache.stats.hits + + grunt.log.ok("#{cacheMisses} files compiled, #{cacheHits} files reused") diff --git a/package.json b/package.json index 6c2e15287..72b420a29 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "jasmine-tagged": "^1.1.4", "jquery": "2.1.4", "key-path-helpers": "^0.4.0", - "less-cache": "0.22", + "less-cache": "0.23", "line-top-index": "0.2.0", "marked": "^0.3.4", "nodegit": "0.9.0",