File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 2727        with :
2828          cache : npm 
2929      - run : npm ci 
30+       - name : Type Definition Check 
31+         run : npm run ci:typecheck 
3032      - name : Test Types 
3133        run : npm run test:types 2>&1 | tee silent.txt; 
3234  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 9898  "scripts" : {
9999    "build" : " node build_releases.js"  ,
100100    "build:types" : " tsc && prettier --write 'types/{**/*,*}.ts'"  ,
101+     "ci:typecheck" : " node ./ci/typecheck.js"  ,
101102    "release" : " node build_releases.js && npm publish"  ,
102103    "test" : " cross-env PARSE_BUILD=node jest"  ,
103104    "test:mongodb" : " npm run test:mongodb:runnerstart && npm run integration"  ,
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments