-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjakefile.js
88 lines (78 loc) · 2.53 KB
/
jakefile.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var cp = require('child_process');
var fs = require('fs');
var path = require('path');
function copyFile(from, to){
var destDir = path.dirname(to);
if( ! fs.existsSync(destDir)){
fs.mkdirSync(destDir);
}
var fromFile = fs.createReadStream(from);
var toFile = fs.createWriteStream(to, { flags: 'w+'});
toFile.once('open', function(fd){
require('util').pump(fromFile, toFile);
});
console.log('copy ' + from + ' -> ' + to);
}
function concatFiles(out, files){
var result = "";
files.forEach(function(file){
result += fs.readFileSync(file) + '\n';
});
fs.writeFileSync(out, result);
}
function exec(command, func){
console.log(command);
//jake.exec(command, {printStdout: true, printStderr: true }, func);
var ex = jake.createExec([command], {printStdout: true, printStderr: true });
ex.addListener('stdout', function (msg) {
console.log('stdout: ' + msg.toString());
});
ex.addListener('stderr', function (msg) {
console.log('stderr: ' + msg.toString());
});
ex.addListener('error', function (msg, code) {
console.log('error(' + code + '): ' + msg.toString());
});
ex.addListener('cmdEnd', func);
ex.run();
}
var commonOptions = [
'src/parser.ts'
];
task('node', function(){
exec('tsc ' + commonOptions.concat(['--out temp', 'src/dtsdoc.ts']).join(' '), function(){
copyFile('src/template.html', 'bin/template.html');
copyFile('temp/dtsdoc/src/dtsdoc.js', 'bin/dtsdoc.js');
copyFile('src/marked.js', 'bin/marked.js');
concatFiles('bin/dtsdoclib.js', [
'temp/Parsect/src/parsect.js',
'temp/Parsect/src/globals.js',
'temp/dtsdoc/src/htmlemitter.js',
'temp/dtsdoc/src/primitives.js',
'temp/dtsdoc/src/links.js',
'temp/dtsdoc/src/type.js',
'temp/dtsdoc/src/parser.js',
'temp/dtsdoc/src/dtsdoclib.js'
]);
});
});
task('web', function(){
exec('tsc ' + commonOptions.concat(['--out web/webdtsdoc.js', 'src/webdtsdoc.ts']).join(' '), function(){
concatFiles('web/webdtsdoc.js', ['web/webdtsdoc.js']);
copyFile('src/template.html', 'web/template.html');
copyFile('src/index.html', 'web/index.html');
copyFile('src/sample.d.ts', 'web/sample.d.ts');
copyFile('src/jquery-1.8.3.js', 'web/jquery-1.8.3.js');
copyFile('src/marked.js', 'web/marked.js');
});
});
task('worker', function(){
exec('tsc ' + commonOptions.concat(['--out web/worker.js', 'src/worker.ts']).join(' '), function(){
concatFiles('web/worker.js', ['src/marked.js', 'web/worker.js']);
});
});
task('default', {async: true}, function() {
jake.Task['web'].invoke();
jake.Task['worker'].invoke();
jake.Task['node'].invoke();
});