diff --git a/script/clean b/script/clean index 499477833..79f31d4b0 100755 --- a/script/clean +++ b/script/clean @@ -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(); diff --git a/src/coffee-cache.coffee b/src/coffee-cache.coffee index 9653b735d..1cb979286 100644 --- a/src/coffee-cache.coffee +++ b/src/coffee-cache.coffee @@ -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 diff --git a/src/less-compile-cache.coffee b/src/less-compile-cache.coffee index feccbac4a..315a0a165 100644 --- a/src/less-compile-cache.coffee +++ b/src/less-compile-cache.coffee @@ -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 = [