v3mt
Version:
A CLI toolkit for managing and deploying Victoria 3 mods, including sending mod files to the game, launching the game, and more.
35 lines (34 loc) • 1.24 kB
JavaScript
import fs from 'fs';
import path from 'path';
import { Config } from '../../utils/config/config.js';
import Logger from '../../utils/logger/logger.js';
import FOLDER_STRUCTURE from './structure.js';
import FOLDER_STRUCTURE_BASIC from './structure-basic.js';
const command = 'setup-mod-folders';
const use = (program) => {
return program
.command(command)
.option('-b, --basic', 'Only setups basic folders')
.description('sets up common mod folders')
.action(task);
};
const setupModFolders = { use, command, task };
export default setupModFolders;
async function task(options) {
const config = Config.fromFile();
const modSource = config.MOD_SOURCE_FOLDER;
if (!modSource) {
Logger.kill("MOD_SOURCE_FOLDER config setting is not set. Please run 'v3mt init'");
}
const structure = options?.basic ? FOLDER_STRUCTURE_BASIC : FOLDER_STRUCTURE;
for (const folder of structure) {
const folderPath = path.join(modSource, folder);
if (!fs.existsSync(folderPath)) {
fs.mkdirSync(folderPath, { recursive: true });
Logger.pass(`Created: ${folder}`);
}
else {
Logger.info(`Exists: ${folder}`);
}
}
}