-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (35 loc) · 1.29 KB
/
index.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
39
40
41
42
const lasso = require('lasso');
const fs = require('fs');
const path = require('path');
module.exports = (lasso, config) => {
let extension = config.extensions || ['ts']
lasso.dependencies.registerRequireType('ts', {
properties: { 'path': 'string' },
init: function (lassoContext) {
const modulePath = this.resolvePath(this.path);
const exec = require('child_process').exec;
return new Promise(function (resolve, reject) {
let childProcess = exec(`tsc ${modulePath}`);
childProcess.stdout.on('data', function (d) { console.log(d); });
childProcess.stderr.on('data', function (d) { console.log(d); });
childProcess.on('exit', function (code) {
if (code !== 0) {
reject();
}
resolve();
});
});
},
getLastModified: function (lassoContext) {
return new Promise((resolve, reject) => {
resolve();
});
},
read: function (lassoContext) {
return (this._compiled && this._compiled.code) || null;
},
getDependencies: function (lassoContext) {
return [];
}
});
};