fix: add 'prompt' argument to loadConfig

This commit is contained in:
MuhammadM1998 2024-06-24 12:43:04 +03:00
parent b271e1e8df
commit 3132236449
4 changed files with 10 additions and 11 deletions

View File

@ -51,10 +51,9 @@ export const add = new Command()
const { loadConfig, add } = frameworksCommands[framework]
// Read config
const config = await loadConfig(cwd, options)
const config = await loadConfig(cwd, options, false)
if (!config) {
consola.warn(`Configuration is missing. Please run ${colors.green('init')} to create a components.json file.`)
process.exit(1)
}

View File

@ -46,13 +46,9 @@ export const diff = new Command()
const { loadConfig, diff } = frameworksCommands[framework]
// Load Config
const config = await loadConfig(cwd, options)
const config = await loadConfig(cwd, options, false)
if (!config) {
consola.warn(
`Configuration is missing. Please run ${colors.green(
'init',
)} to create a components.json file.`,
)
consola.warn(`Configuration is missing. Please run ${colors.green('init')} to create a components.json file.`)
process.exit(1)
}

View File

@ -16,9 +16,9 @@ import {
resolveConfigPaths,
} from '../../../utils/get-config'
export default async function (cwd: string, options: { yes: boolean, cwd: string }) {
export default async function (cwd: string, options: { yes: boolean, cwd: string }, prompt: boolean) {
const existingConfig = await getConfig(cwd)
return await promptForConfig(cwd, existingConfig, options.yes)
return prompt ? await promptForConfig(cwd, existingConfig, options.yes) : existingConfig
}
async function promptForConfig(

View File

@ -40,7 +40,11 @@ export const init = new Command()
const { loadConfig, init } = frameworksCommands[framework]
// Read config
const config = await loadConfig(cwd, options)
const config = await loadConfig(cwd, options, true)
if (!config) {
consola.error(`Error loading config. Please run the ${colors.green('init')} command again.`)
process.exit(1)
}
// Init
await init(cwd, config)