File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
const fs = require ( 'fs' )
5
5
const path = require ( 'path' )
6
+ const tslint = require ( 'tslint' )
6
7
7
8
const fetchDocs = require ( './vendor/fetch-docs' )
8
9
const generateTypings = require ( './' )
@@ -37,10 +38,20 @@ if (inFile) {
37
38
apiPromise . then ( API => {
38
39
return JSON . parse ( JSON . stringify ( API ) )
39
40
} ) . then ( API => {
40
- let outStream = process . stdout
41
- if ( outFile ) {
42
- outStream = fs . createWriteStream ( path . resolve ( process . cwd ( ) , outFile ) )
43
- }
41
+ const output = generateTypings ( API ) . join ( '\n' ) + '\n'
42
+ const linter = new tslint . Linter ( { } )
43
+ const configuration = tslint . Configuration . findConfiguration (
44
+ path . join ( __dirname , 'tslint.json' ) , outFile
45
+ ) . results
46
+ linter . lint ( outFile , output , configuration )
47
+ const result = linter . getResult ( )
44
48
45
- generateTypings ( API ) . forEach ( line => outStream . write ( `${ line } \n` ) )
49
+ if ( result . failureCount === 0 ) {
50
+ fs . writeFileSync ( outFile , output )
51
+ process . exit ( 0 )
52
+ } else {
53
+ console . error ( 'Failed to lint electron.d.ts' )
54
+ console . error ( result )
55
+ process . exit ( 1 )
56
+ }
46
57
} )
You can’t perform that action at this time.
0 commit comments