fix(config-manager): Add silent mode check and improve test mocking for ensureConfigFileExists

This commit is contained in:
Eyal Toledano
2025-06-05 13:33:20 -04:00
parent f12fc476d3
commit a9c1b6bbcf
2 changed files with 29 additions and 3 deletions

View File

@@ -2,7 +2,12 @@ import fs from "fs";
import path from "path";
import chalk from "chalk";
import { fileURLToPath } from "url";
import { log, findProjectRoot, resolveEnvVariable } from "./utils.js";
import {
log,
findProjectRoot,
resolveEnvVariable,
isSilentMode,
} from "./utils.js";
// Calculate __dirname in ESM
const __filename = fileURLToPath(import.meta.url);
@@ -842,7 +847,11 @@ function ensureConfigFileExists(explicitRoot = null) {
try {
// Create the default config file (following writeConfig pattern)
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
console.log(chalk.blue(` Created default .taskmasterconfig file`));
// Only log if not in silent mode
if (!isSilentMode()) {
console.log(chalk.blue(` Created default .taskmasterconfig file`));
}
// Clear any cached config to ensure fresh load
loadedConfig = null;