UNPKG

v3mt

Version:

A CLI toolkit for managing and deploying Victoria 3 mods, including sending mod files to the game, launching the game, and more.

37 lines (36 loc) 1.2 kB
import { exec } from 'child_process'; import Logger from '../utils/logger/logger.js'; const VICTORIA3_GAME_ID = '529340'; const command = 'launch-game'; const use = (program) => { return program .command(command) .description('Launch the game') .option('-n, --no-debug', 'Launch game without debug mode') .option('-i, --id <id>', 'Steam Game ID', VICTORIA3_GAME_ID) .action(task); }; const launchGame = { use, command }; export default launchGame; function task(options) { const steamGameId = options.id; if (!steamGameId) { Logger.kill('Steam Game ID is not set.'); } const debugArg = options.noDebug ? '' : '-debug_mode'; const steamUrl = `steam://rungameid/${steamGameId}//${debugArg}`; const commands = { win32: 'start ""', darwin: 'open', linux: 'xdg-open', }; const command = commands[process.platform]; if (!command) { Logger.kill(`Unsupported platform: ${process.platform}`); } exec(`${command} "${steamUrl}"`, (error, stdout, stderr) => { if (error) { Logger.kill(`Error launching game: ${stderr || stdout || error.message}`); } }); }