-
Notifications
You must be signed in to change notification settings - Fork 0
/
lasso-dust-plugin.js
38 lines (31 loc) · 1.11 KB
/
lasso-dust-plugin.js
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
33
34
35
36
37
38
var compiler = require('dustc-commonjs');
module.exports = function(lasso, config) {
lasso.dependencies.registerRequireType(
'dust',
{
properties: {
'path': 'string'
},
init: function(lassoContext, callback) {
if (!this.path) {
const missingPathErr = new Error('"path" is required for a Dust dependency');
if (callback) {
return callback(missingPathErr);
} else {
throw missingPathErr;
}
}
this.path = this.resolvePath(this.path);
if (callback) callback();
},
read: function(lassoContext, callback) {
return compiler.compileFile(this.path, callback);
},
getSourceFile: function() {
return this.path;
},
getLastModified: function(lassoContext, callback) {
return lassoContext.getFileLastModified(this.path, callback);
}
});
};