2013-09-17 01:57:48 +04:00
|
|
|
path = require 'path'
|
|
|
|
|
|
|
|
LessCache = require 'less-cache'
|
|
|
|
|
|
|
|
module.exports = (grunt) ->
|
|
|
|
grunt.registerMultiTask 'prebuild-less', 'Prebuild cached of compiled LESS files', ->
|
|
|
|
prebuiltConfigurations = [
|
|
|
|
['atom-dark-ui', 'atom-dark-syntax']
|
|
|
|
['atom-dark-ui', 'atom-light-syntax']
|
2013-09-18 01:09:54 +04:00
|
|
|
['atom-dark-ui', 'solarized-dark-syntax']
|
2013-09-18 01:10:11 +04:00
|
|
|
['atom-dark-ui', 'base16-tomorrow-dark-theme']
|
2013-09-17 01:57:48 +04:00
|
|
|
['atom-light-ui', 'atom-light-syntax']
|
|
|
|
['atom-light-ui', 'atom-dark-syntax']
|
2013-09-18 01:09:54 +04:00
|
|
|
['atom-light-ui', 'solarized-dark-syntax']
|
2013-09-18 01:10:11 +04:00
|
|
|
['atom-light-ui', 'base16-tomorrow-dark-theme']
|
2013-09-17 01:57:48 +04:00
|
|
|
]
|
|
|
|
|
|
|
|
directory = path.join(grunt.config.get('atom.appDir'), 'less-compile-cache')
|
|
|
|
|
|
|
|
for configuration in prebuiltConfigurations
|
2013-09-17 03:23:59 +04:00
|
|
|
importPaths = grunt.config.get('less.options.paths')
|
2013-09-17 02:48:23 +04:00
|
|
|
themeMains = []
|
2013-09-17 01:57:48 +04:00
|
|
|
for theme in configuration
|
2013-09-17 02:35:45 +04:00
|
|
|
# TODO Use AtomPackage class once it runs outside of an Atom context
|
2013-09-17 02:48:23 +04:00
|
|
|
themePath = path.resolve('node_modules', theme)
|
|
|
|
stylesheetsDir = path.join(themePath, 'stylesheets')
|
|
|
|
{main} = grunt.file.readJSON(path.join(themePath, 'package.json'))
|
|
|
|
main ?= 'index.less'
|
|
|
|
mainPath = path.join(themePath, main)
|
|
|
|
themeMains.push(mainPath) if grunt.file.isFile(mainPath)
|
|
|
|
importPaths.unshift(stylesheetsDir) if grunt.file.isDir(stylesheetsDir)
|
2013-09-17 01:57:48 +04:00
|
|
|
|
|
|
|
grunt.log.writeln("Building LESS cache for #{configuration.join(', ').yellow}")
|
|
|
|
lessCache = new LessCache
|
|
|
|
cacheDir: directory
|
|
|
|
resourcePath: path.resolve('.')
|
|
|
|
importPaths: importPaths
|
|
|
|
|
|
|
|
for file in @filesSrc
|
|
|
|
grunt.log.writeln("File #{file.cyan} created in cache.")
|
|
|
|
lessCache.readFileSync(file)
|
2013-09-17 02:48:23 +04:00
|
|
|
|
|
|
|
for file in themeMains
|
|
|
|
grunt.log.writeln("File #{file.cyan} created in cache.")
|
|
|
|
lessCache.readFileSync(file)
|