-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 747 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 747 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
var livescript = require('LiveScript');
var path = require('path');
var fs = require('fs');
module.exports = function (builder) {
builder.hook('before scripts', function (pkg, next) {
if (pkg.config.scripts === undefined) {
return next();
}
var ls = pkg.config.scripts.filter(function(file) {
return path.extname(file) === '.ls';
});
if (ls.length === 0) {
return next();
}
ls.forEach(function (file) {
var realpath = pkg.path(file);
var str = fs.readFileSync(realpath, 'utf8');
var compiled = livescript.compile(str, { filename: realpath, bare: true });
var filename = file.replace('.ls', '.js');
pkg.addFile('scripts', filename, compiled);
pkg.removeFile('scripts', file);
});
next();
});
};