Skip to content

Commit f0e8658

Browse files
Merge pull request #41 from electron/check-output-on-gen
Run tsc on the output at gen time
2 parents b39769a + be5cd60 commit f0e8658

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

cli.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22
'use strict'
33

4+
const childProcess = require('child_process')
45
const fs = require('fs')
56
const path = require('path')
67
const tslint = require('tslint')
@@ -35,6 +36,20 @@ if (inFile) {
3536
apiPromise = fetchDocs()
3637
}
3738

39+
const typeCheck = () => {
40+
const tscExec = path.resolve(require.resolve('typescript'), '../../bin/tsc')
41+
const tscChild = childProcess.spawn(tscExec, ['--project', 'tsconfig.json'], {
42+
cwd: path.resolve(__dirname, 'test-smoke/electron')
43+
})
44+
tscChild.stdout.on('data', d => console.log(d.toString()))
45+
tscChild.stderr.on('data', d => console.error(d.toString()))
46+
tscChild.on('exit', (tscStatus) => {
47+
if (tscStatus !== 0) {
48+
process.exit(tscStatus)
49+
}
50+
})
51+
}
52+
3853
apiPromise.then(API => {
3954
return JSON.parse(JSON.stringify(API))
4055
}).then(API => {
@@ -48,7 +63,9 @@ apiPromise.then(API => {
4863

4964
if (result.failureCount === 0) {
5065
fs.writeFileSync(outFile, output)
51-
process.exit(0)
66+
fs.writeFileSync(path.resolve(__dirname, 'test-smoke/electron/index.d.ts'), output)
67+
68+
typeCheck()
5269
} else {
5370
console.error('Failed to lint electron.d.ts')
5471
console.error(result)

0 commit comments

Comments
 (0)