|
6 | 6 | const enquirer = require('enquirer')
|
7 | 7 | const figlet = require('figlet')
|
8 | 8 | const chalk = require('chalk')
|
| 9 | + const vdf_parser = require('vdf-parser') |
9 | 10 | const appDirectory = require('path').dirname(process.pkg ? process.execPath : (require.main ? require.main.filename : process.argv[0])).replace(/\\/g, '/')
|
10 | 11 | let i;
|
11 | 12 |
|
|
15 | 16 | horizontalLayout: 'fitted',
|
16 | 17 | verticalLayout: 'fitted'
|
17 | 18 | }) + chalk.blueBright('v1.1.0 stable')))
|
18 |
| - console.log(chalk.magenta(`A utility designed to help make installing CSSource textures into Garry\s Mod ${chalk.blue('safe')} while also doing it the ${chalk.blue('legal method')} by utilizing steamcmd.`)) |
| 19 | + console.log(chalk.magenta(`A utility designed to help make installing CSSource textures into Garry's Mod ${chalk.blue('safe')} while also using the ${chalk.blue('legal method')} by utilizing steamcmd.`)) |
19 | 20 | console.log(chalk.hex('#7289DA')(`Have any questions? Join my discord: https://discord.gg/kb4KREA`))
|
20 | 21 | progress.start('Verifying steam directory...')
|
21 | 22 |
|
|
41 | 42 | return progress.fail('Steam could not be found on your computer.\nAutomatically closing window in 10 seconds.', 10000)
|
42 | 43 | }
|
43 | 44 | progress.succeed(`Steam installation directory found: ${steamIPath}`)
|
44 |
| - const gmodIPath = `${steamIPath}/steamapps/common/GarrysMod/garrysmod` |
45 |
| - progress.start('Verifying Garrys Mod directory...') |
46 |
| - if (!fs.existsSync(gmodIPath)) return progress.fail('Garrys Mod could not be found on your computer.\nAutomatically closing window in 10 seconds.', 10000) |
| 45 | + let gmodIPath = await (async () => { |
| 46 | + return new Promise(function (resolve) { |
| 47 | + if (fs.existsSync(steamIPath + "/steamapps/appmanifest_4000.acf")) { |
| 48 | + resolve(steamIPath + "/steamapps/common/GarrysMod") |
| 49 | + } else if (fs.existsSync(steamIPath + "/steamapps/libraryfolders.vdf")) { |
| 50 | + var libraryfolders_vdf = vdf_parser.parse(fs.readFileSync(steamIPath + "/steamapps/libraryfolders.vdf").toString()) |
| 51 | + if ("libraryfolders" in libraryfolders_vdf) { |
| 52 | + for (e in libraryfolders_vdf["libraryfolders"]) { |
| 53 | + var _e = libraryfolders_vdf["libraryfolders"][e] |
| 54 | + if ("4000" in _e["apps"]) { |
| 55 | + resolve(_e["path"].replace("\\\\", "/") + "/steamapps/common/GarrysMod") |
| 56 | + return |
| 57 | + } |
| 58 | + } |
| 59 | + resolve(false) |
| 60 | + } else resolve(false) |
| 61 | + } else resolve(false) |
| 62 | + }) |
| 63 | + })() |
| 64 | + if (!gmodIPath) { |
| 65 | + return progress.fail('Garrys Mod could not be found on your computer.\nAutomatically closing window in 10 seconds.', 10000) |
| 66 | + } |
47 | 67 | progress.succeed(`Garrys Mod installation directory found: ${gmodIPath}`)
|
48 | 68 | progress.start('Checking for steamcmd...')
|
49 | 69 | if (!fs.existsSync(appDirectory + '/steam/steamcmd.exe')) {
|
|
0 commit comments