import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname } from 'node:path';

const configPath = '/home/nandi/.config/obs-studio/plugin_config/obs-websocket/config.json';

const current = JSON.parse(readFileSync(configPath, 'utf8')) as Record<string, unknown>;
current.server_enabled = true;
current.server_port = 4455;

mkdirSync(dirname(configPath), { recursive: true });
writeFileSync(configPath, JSON.stringify(current, null, 2) + '\n');

console.log(configPath);
console.log(JSON.stringify({
  server_enabled: current.server_enabled,
  server_port: current.server_port,
  auth_required: current.auth_required,
}, null, 2));

