File tree 3 files changed +39
-3
lines changed
3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 27
27
with :
28
28
cache : npm
29
29
- run : npm ci
30
- - name : Build Types
31
- run : npm run build:types
30
+ - name : Type Definition Check
31
+ run : npm run ci:typecheck
32
32
- name : Test Types
33
33
run : npm run test:types 2>&1 | tee silent.txt;
34
34
check-docs :
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' ) . promises ;
2
+ const { exec } = require ( 'child_process' ) ;
3
+ const util = require ( 'util' ) ;
4
+
5
+ async function getTypes ( files ) {
6
+ const types = { } ;
7
+ const promise = files . map ( ( file ) => {
8
+ if ( file . includes ( '.d.ts' ) ) {
9
+ return fs . readFile ( `./types/${ file } ` , 'utf8' ) . then ( ( content ) => {
10
+ types [ file ] = content ;
11
+ } ) ;
12
+ }
13
+ } ) ;
14
+ await Promise . all ( promise ) ;
15
+ return types ;
16
+ }
17
+
18
+ ( async ( ) => {
19
+ const execute = util . promisify ( exec ) ;
20
+ const currentFiles = await fs . readdir ( './types' ) ;
21
+ const currentTypes = await getTypes ( currentFiles ) ;
22
+ await execute ( 'npm run build:types' ) ;
23
+ const newFiles = await fs . readdir ( './types' ) ;
24
+ const newTypes = await getTypes ( newFiles ) ;
25
+ for ( const file of newFiles ) {
26
+ if ( currentTypes [ file ] !== newTypes [ file ] ) {
27
+ console . error (
28
+ '\x1b[31m%s\x1b[0m' ,
29
+ 'Type definitions files cannot be updated manually. Use `npm run build:types` to generate type definitions.'
30
+ ) ;
31
+ process . exit ( 1 ) ;
32
+ }
33
+ }
34
+ process . exit ( 0 ) ;
35
+ } ) ( ) ;
Original file line number Diff line number Diff line change 97
97
},
98
98
"scripts" : {
99
99
"build" : " node build_releases.js" ,
100
- "build:types" : " tsc && prettier --write 'types/{**/*,*}.ts' && npm run lint:fix" ,
100
+ "build:types" : " tsc && prettier --write 'types/{**/*,*}.ts'" ,
101
+ "ci:typecheck" : " node ./ci/typecheck.js" ,
101
102
"release" : " node build_releases.js && npm publish" ,
102
103
"test" : " cross-env PARSE_BUILD=node jest" ,
103
104
"test:mongodb" : " npm run test:mongodb:runnerstart && npm run integration" ,
You can’t perform that action at this time.
0 commit comments