This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
169 lines (149 loc) · 2.79 KB
/
Gruntfile.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
module.exports = function (grunt) {
'use strict';
require('source-map-support').install();
var path = require('path');
var childProcess = require('child_process');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-tslint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json')
},
src: ['src/**/*.ts'],
test: ['test/src/**/*.ts']
},
clean: {
cruft: [
'tscommand-*.tmp.txt'
],
dist: [
'src/**/*.js',
'src/**/*.js.map',
'src/**/*.d.ts',
],
tmp: {
dot: true,
src: [
'tmp/'
]
},
test: [
'test/tmp/**/*'
]
},
ts: {
default: {
tsconfig: {
tsconfig: "./tsconfig.json",
updateFiles:false
}
}
},
exec: {
test: {
options: {
full: (process.env.TRAVIS === 'true')
}
}
}
});
grunt.registerMultiTask('exec', function () {
var options = this.options({
full: true
});
var done = this.async();
var run = function (target) {
var args = [];
args.push(path.resolve(__dirname, 'src', 'index.js'));
if (options.tests) {
args.push('--tests');
}
if (options.lint) {
args.push('--lint');
}
if (options.changes) {
args.push('--changes');
}
if (options.debug) {
args.push('--debug');
}
args.push('--path', target);
var opts = {
cwd: target,
stdio: 'inherit'
};
childProcess.spawn('node', args, opts).on('close', function (code) {
console.log('child process exited with code ' + code);
done((code === 0));
});
};
if (!options.full) {
// TODO prepare shrinked DT repo
void 0;
}
var fs = require('fs');
var repoDir = path.join(__dirname, 'tmp');
fs.mkdirSync(repoDir);
var Git = require('git-wrapper');
var git = new Git({
'git-dir': path.join(repoDir, '.git')
});
var opts = {
depth: 20
};
var args = [
'https://github.com/borisyankov/DefinitelyTyped',
repoDir
];
console.log('cloning repos..');
git.exec('clone', opts, args, function (err, msg) {
console.log(msg);
if (err) {
done(err);
}
else {
run(repoDir);
}
});
});
grunt.registerTask('dev', [
'prep',
'ts',
'exec'
]);
grunt.registerTask('run', [
'clean:tmp',
'exec'
]);
grunt.registerTask('prep', [
'clean:tmp',
'clean:dist',
'clean:cruft'
]);
grunt.registerTask('compile', [
'prep',
'ts',
'tslint:src'
]);
grunt.registerTask('build', [
'compile',
'sweep'
]);
grunt.registerTask('test', [
'build',
'exec'
]);
grunt.registerTask('prepublish', [
'build'
]);
grunt.registerTask('sweep', [
'clean:cruft',
'clean:tmp',
'clean:test'
]);
grunt.registerTask('debug', ['build']);
grunt.registerTask('default', ['build']);
};