1- //@ts -check
2-
3- const { execSync } = require ( 'child_process' ) ;
41const fs = require ( 'fs' ) ;
52const os = require ( 'os' ) ;
63const path = require ( 'path' ) ;
@@ -25,25 +22,25 @@ const CONPTY_SUPPORTED_ARCH = ['x64', 'arm64'];
2522console . log ( '\x1b[32m> Cleaning release folder...\x1b[0m' ) ;
2623
2724function cleanFolderRecursive ( folder ) {
28- var files = [ ] ;
25+ let files = [ ] ;
2926 if ( fs . existsSync ( folder ) ) {
3027 files = fs . readdirSync ( folder ) ;
31- files . forEach ( function ( file , index ) {
32- var curPath = path . join ( folder , file ) ;
33- if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // recurse
34- cleanFolderRecursive ( curPath ) ;
35- fs . rmdirSync ( curPath ) ;
36- } else if ( BUILD_FILES . indexOf ( curPath ) < 0 ) { // delete file
37- fs . unlinkSync ( curPath ) ;
28+ for ( let file of files ) {
29+ let currentPath = path . join ( folder , file ) ;
30+ if ( fs . lstatSync ( currentPath ) . isDirectory ( ) ) {
31+ cleanFolderRecursive ( currentPath ) ;
32+ fs . rmdirSync ( currentPath ) ;
33+ } else if ( ! BUILD_FILES . includes ( currentPath ) ) {
34+ fs . unlinkSync ( currentPath ) ;
3835 }
39- } ) ;
36+ }
4037 }
4138} ;
4239
4340try {
4441 cleanFolderRecursive ( RELEASE_DIR ) ;
45- } catch ( e ) {
46- console . log ( e ) ;
42+ } catch ( err ) {
43+ console . error ( err ) ;
4744 process . exit ( 1 ) ;
4845}
4946
@@ -76,8 +73,3 @@ if (os.platform() !== 'win32') {
7673 }
7774 }
7875}
79-
80- console . log ( `\x1b[32m> Generating compile_commands.json...\x1b[0m` ) ;
81- execSync ( 'npx node-gyp configure -- -f compile_commands_json' ) ;
82-
83- process . exit ( 0 ) ;
0 commit comments