Skip to content

Commit 5d66d70

Browse files
committed
tslint output before creating file
1 parent 64416fe commit 5d66d70

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

cli.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const fs = require('fs')
55
const path = require('path')
6+
const tslint = require('tslint')
67

78
const fetchDocs = require('./vendor/fetch-docs')
89
const generateTypings = require('./')
@@ -37,10 +38,20 @@ if (inFile) {
3738
apiPromise.then(API => {
3839
return JSON.parse(JSON.stringify(API))
3940
}).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()
4448

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+
}
4657
})

0 commit comments

Comments
 (0)