🐎 Cache compiled CSON files

This configures season to use a cache directory similar to the
coffee cache so that dev windows don't have to recompile CSON file
on each load.

This shaves hundreds of milliseconds off of the dev window load time.

The cached CSON files are located in /tmp/atom-compile-cache/cson
This commit is contained in:
Kevin Sawicki
2013-09-21 10:41:13 -07:00
parent e254e95792
commit f4266b5f6a
2 changed files with 6 additions and 3 deletions

View File

@@ -31,7 +31,7 @@
"pegjs": "0.7.0",
"plist": "git://github.com/nathansobo/node-plist.git",
"rimraf": "2.1.4",
"season": "0.12.0",
"season": "0.13.0",
"semver": "1.1.4",
"space-pen": "1.2.0",
"tantamount": "0.3.0",

View File

@@ -3,13 +3,16 @@ fs = require 'fs'
path = require 'path'
CoffeeScript = require 'coffee-script'
CSON = require 'season'
mkdir = require('mkdirp').sync
cacheDir = '/tmp/atom-compile-cache/coffee'
cacheDir = '/tmp/atom-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(cacheDir, "#{digest}.coffee")
path.join(coffeeCacheDir, "#{digest}.coffee")
getCachedJavaScript = (cachePath) ->
try