diff --git a/packages/api/core/src/api/init.ts b/packages/api/core/src/api/init.ts index 2e678db8e0..29494e7d23 100644 --- a/packages/api/core/src/api/init.ts +++ b/packages/api/core/src/api/init.ts @@ -86,7 +86,7 @@ export default async ({ dir = process.cwd(), interactive = false, copyCIFiles = title: 'Initializing template', task: async ({ templateModule }, task) => { if (typeof templateModule.initializeTemplate === 'function') { - const tasks = await templateModule.initializeTemplate(dir, { copyCIFiles }); + const tasks = await templateModule.initializeTemplate(dir, { copyCIFiles, force }); if (tasks) { return task.newListr(tasks, { concurrent: false }); } diff --git a/packages/template/vite/src/ViteTemplate.ts b/packages/template/vite/src/ViteTemplate.ts index b6401d1d0b..a2aba76e5f 100644 --- a/packages/template/vite/src/ViteTemplate.ts +++ b/packages/template/vite/src/ViteTemplate.ts @@ -43,7 +43,7 @@ class ViteTemplate extends BaseTemplate { // TODO: Compatible with any path entry. // Vite uses index.html under the root path as the entry point. - fs.moveSync(path.join(directory, 'src', 'index.html'), path.join(directory, 'index.html')); + fs.moveSync(path.join(directory, 'src', 'index.html'), path.join(directory, 'index.html'), { overwrite: options.force }); await this.updateFileByLine(path.join(directory, 'index.html'), (line) => { if (line.includes('link rel="stylesheet"')) return ''; if (line.includes('')) return ' \n '; diff --git a/packages/utils/types/src/index.ts b/packages/utils/types/src/index.ts index 52099ac25c..c7c7989726 100644 --- a/packages/utils/types/src/index.ts +++ b/packages/utils/types/src/index.ts @@ -214,6 +214,7 @@ export type StartResult = InnerStartResult | { tasks: ForgeListrTaskDefinition[] export interface InitTemplateOptions { copyCIFiles?: boolean; + force?: boolean; } // eslint-disable-next-line @typescript-eslint/no-explicit-any