Merge pull request #1879 from atom/ks-move-compile-cache-to-dot-atom

Move compile cache to ~/.atom/compile-cache
This commit is contained in:
Kevin Sawicki
2014-04-17 18:54:30 -07:00
3 changed files with 9 additions and 15 deletions

View File

@@ -23,9 +23,9 @@ var commands = [
[home, '.atom', '.node-gyp'],
[home, '.atom', 'storage'],
[home, '.atom', '.npm'],
[home, '.atom', 'compile-cache'],
[tmpdir, 'atom-build'],
[tmpdir, 'atom-cached-atom-shells'],
[tmpdir, 'atom-compile-cache'],
];
var run = function() {
var next = commands.shift();

View File

@@ -1,33 +1,29 @@
crypto = require 'crypto'
fs = require 'fs'
path = require 'path'
os = require 'os'
CoffeeScript = require 'coffee-script'
CSON = require 'season'
mkdir = require('mkdirp').sync
fs = require 'fs-plus'
tmpDir = if process.platform is 'win32' then os.tmpdir() else '/tmp'
cacheDir = path.join(tmpDir, 'atom-compile-cache')
cacheDir = path.join(fs.getHomeDirectory(), 'compile-cache')
coffeeCacheDir = path.join(cacheDir, 'coffee')
CSON.setCacheDir(path.join(cacheDir, 'cson'))
getCachePath = (coffee) ->
digest = crypto.createHash('sha1').update(coffee, 'utf8').digest('hex')
path.join(coffeeCacheDir, "#{digest}.coffee")
path.join(coffeeCacheDir, "#{digest}.js")
getCachedJavaScript = (cachePath) ->
if stat = fs.statSyncNoException(cachePath)
if fs.isFileSync(cachePath)
try
fs.readFileSync(cachePath, 'utf8') if stat.isFile()
fs.readFileSync(cachePath, 'utf8')
compileCoffeeScript = (coffee, filePath, cachePath) ->
{js,v3SourceMap} = CoffeeScript.compile(coffee, filename: filePath, sourceMap: true)
{js, v3SourceMap} = CoffeeScript.compile(coffee, filename: filePath, sourceMap: true)
# Include source map in the web page environment.
if btoa? and JSON? and unescape? and encodeURIComponent?
js = "#{js}\n//# sourceMappingURL=data:application/json;base64,#{btoa unescape encodeURIComponent v3SourceMap}\n//# sourceURL=#{filePath}"
try
mkdir(path.dirname(cachePath))
fs.writeFileSync(cachePath, js)
js

View File

@@ -1,16 +1,14 @@
path = require 'path'
os = require 'os'
fs = require 'fs-plus'
LessCache = require 'less-cache'
{Subscriber} = require 'emissary'
tmpDir = if process.platform is 'win32' then os.tmpdir() else '/tmp'
# {LessCache} wrapper used by {ThemeManager} to read stylesheets.
module.exports =
class LessCompileCache
Subscriber.includeInto(this)
@cacheDir: path.join(tmpDir, 'atom-compile-cache', 'less')
@cacheDir: path.join(fs.getHomeDirectory(), 'compile-cache', 'less')
constructor: ({resourcePath, importPaths}) ->
@lessSearchPaths = [