Skip to content

Commit

Permalink
fix(template-vite): make --force flag work (#3825)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Jan 29, 2025
1 parent 062ec75 commit f084010
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api/core/src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/template/vite/src/ViteTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('</body>')) return ' <script type="module" src="/src/renderer.js"></script>\n </body>';
Expand Down
1 change: 1 addition & 0 deletions packages/utils/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f084010

Please sign in to comment.