-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwrapper.js
More file actions
32 lines (23 loc) · 778 Bytes
/
wrapper.js
File metadata and controls
32 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// CoffeeScript (JS) wrapper for SocketStream 0.3 and 0.4.x
var fs = require('fs'),
coffee = require('coffeescript');
exports.init = function(root, config) {
coffee.register();
return {
name: 'CoffeeScript',
extensions: ['coffee'],
assetType: 'js',
contentType: 'text/javascript; charset=utf-8',
compile: function(path, options, cb) {
var input = fs.readFileSync(path, 'utf8');
try {
cb( coffee.compile(input, {bare: true}) );
} catch (e) {
var message = "! Error compiling " + path + " into CoffeeScript";
console.log(String.prototype.hasOwnProperty('red') && message.red || message);
cb("Error compiling to CoffeeScript: " + e.stack);
throw new Error(e);
}
}
};
};