11const { getDirectory, getMinecraftDir } = require ( "./util" )
22const { join } = require ( "path" )
33const { spawn, } = require ( "child_process" )
4- const { readFileSync, rmSync, cpSync, readdirSync } = require ( "fs" )
4+ const { readFileSync, rmSync, cpSync, readdirSync, existsSync } = require ( "fs" )
55const { platform } = require ( "os" )
66const { arch, env, stdout } = require ( "process" )
77const { downloadMeta } = require ( "./download/metadownloader" )
@@ -188,7 +188,7 @@ const launch = (version, account, statusCallback) => {
188188 } else arguments . push ( arg )
189189 } )
190190 rmSync ( join ( getDirectory ( ) , 'tmpmods' ) , { recursive : true , force : true } )
191- cpSync ( join ( dir , 'mods' ) , join ( getDirectory ( ) , 'tmpmods' ) , { recursive : true , force : true } )
191+ if ( existsSync ( join ( dir , 'mods' ) ) ) cpSync ( join ( dir , 'mods' ) , join ( getDirectory ( ) , 'tmpmods' ) , { recursive : true , force : true } )
192192 rmSync ( join ( dir , 'mods' ) , { recursive : true , force : true } )
193193 log ( 'Launching...' )
194194 const process = spawn ( join ( getJavaPath ( meta . javaVersion . component ) , 'bin' , 'javaw' ) , insertValues ( arguments , values ) , {
@@ -198,7 +198,7 @@ const launch = (version, account, statusCallback) => {
198198 } )
199199 process . stdout . on ( 'data' , data => {
200200 if ( data . toString ( ) . includes ( 'Loading ' ) && data . toString ( ) . includes ( ' mods:' ) ) {
201- cpSync ( join ( getDirectory ( ) , 'tmpmods' ) , join ( dir , 'mods' ) , { recursive : true , force : true } )
201+ if ( existsSync ( join ( getDirectory ( ) , 'tmpmods' ) ) ) cpSync ( join ( getDirectory ( ) , 'tmpmods' ) , join ( dir , 'mods' ) , { recursive : true , force : true } )
202202 }
203203 } ) . pipe ( stdout )
204204 process . unref ( )
0 commit comments