@@ -44,6 +44,14 @@ function createVenv() {
4444 }
4545}
4646
47+ function deleteVenv ( ) {
48+ const venvPath = path . join ( projectPath , "venv" ) ;
49+ if ( fs . existsSync ( venvPath ) ) {
50+ console . log ( `→ Removing virtual environment → ${ venvPath } ` ) ;
51+ fs . rmSync ( venvPath , { recursive : true , force : true } ) ;
52+ }
53+ }
54+
4755function installDependecies ( pythonExe ) {
4856 console . log ( `→ Installing dependencies ...` ) ;
4957 const pipCommand = `pip install ${ projectPath } pyinstaller` ;
@@ -60,9 +68,10 @@ function installDependecies(pythonExe) {
6068
6169function runPyInstaller ( pythonExe ) {
6270 console . log ( `→ Running PyInstaller ...` ) ;
63- const specFiles = fs . readdirSync ( projectPath , { withFileTypes : true } )
64- . filter ( file => file . isFile ( ) && file . name . endsWith ( ".spec" ) )
65- . map ( file => path . join ( projectPath , file . name ) ) ;
71+ const specFiles = fs
72+ . readdirSync ( projectPath , { withFileTypes : true } )
73+ . filter ( ( file ) => file . isFile ( ) && file . name . endsWith ( ".spec" ) )
74+ . map ( ( file ) => path . join ( projectPath , file . name ) ) ;
6675 if ( specFiles . length !== 1 ) {
6776 console . error ( "Expected 1 spec file, found " + specFiles . length ) ;
6877 process . exit ( 1 ) ;
@@ -83,6 +92,7 @@ function main() {
8392 const pythonExe = createVenv ( ) ;
8493 installDependecies ( pythonExe ) ;
8594 runPyInstaller ( pythonExe ) ;
95+ deleteVenv ( ) ;
8696}
8797
8898main ( ) ;
0 commit comments