File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ var _ = require ( 'lodash' ) ;
2
+ var colors = require ( 'colors' ) ;
3
+ var glob = require ( 'glob' ) ;
4
+ var fs = require ( 'fs' ) ;
5
+ var ts = require ( 'typescript' ) ;
6
+
7
+ function diagnose ( fileNames , options ) {
8
+ var program = ts . createProgram ( fileNames , options ) ;
9
+
10
+ var diagnostics = _ . groupBy ( ts . getPreEmitDiagnostics ( program ) ,
11
+ function ( x ) {
12
+ return x . file . fileName ;
13
+ } ) ;
14
+
15
+ _ . forIn ( diagnostics , function ( value , key ) {
16
+ fs . readFile ( key , 'utf-8' , function ( err , file ) {
17
+ console . log ( key ) ;
18
+
19
+ var lines = file . split ( '\n' ) ;
20
+ _ . forEach ( value , function ( diagnostic ) {
21
+ var pos = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
22
+ var message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
23
+
24
+ console . log ( 'Error : ' . red + message ) ;
25
+ console . log ( lines [ pos . line ] . gray ) ;
26
+ console . log ( _ . repeat ( ' ' , pos . character ) + '^' ) ;
27
+ console . log ( ) ;
28
+ } ) ;
29
+ } ) ;
30
+ } ) ;
31
+ }
32
+
33
+ glob ( './**/*.ts' , function ( err , files ) {
34
+ files . unshift ( '../typings/es6-shim/es6-shim.d.ts' ) ;
35
+ diagnose ( files , {
36
+ module : ts . ModuleKind . CommonJS
37
+ } ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments