-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SHA-1 based CoffeeScript compile cache
This restores the require cache that was used pre-node integration
- Loading branch information
1 parent
e10f06e
commit bc76b70
Showing
7 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
crypto = require 'crypto' | ||
fs = require 'fs' | ||
path = require 'path' | ||
|
||
CoffeeScript = require 'coffee-script' | ||
mkdir = require('mkdirp').sync | ||
|
||
getCachePath = (coffeeContents)-> | ||
digest = crypto.createHash('sha1').update(coffeeContents, 'utf8').digest('hex') | ||
path.join('/tmp/atom-compile-cache/coffee', "#{digest}.coffee") | ||
|
||
require.extensions['.coffee'] = (module, filePath) -> | ||
coffeeContents = fs.readFileSync(filePath, 'utf8') | ||
cachePath = getCachePath(coffeeContents) | ||
try | ||
jsContents = fs.readFileSync(cachePath, 'utf8') if fs.statSync(cachePath).isFile() | ||
|
||
unless jsContents? | ||
jsContents = CoffeeScript.compile(coffeeContents, filename: filePath) | ||
try | ||
mkdir(path.dirname(cachePath)) | ||
fs.writeFileSync(cachePath, jsContents) | ||
|
||
module._compile(jsContents, filePath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters