Skip to content

Commit

Permalink
fix: addWatchFiles && fileChange hook not work (#6599)
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin authored Dec 4, 2024
1 parent e543dc9 commit b0b8847
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-sloths-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/app-tools': patch
'@modern-js/plugin-v2': patch
---

fix: addWatchFiles hook not work
2 changes: 1 addition & 1 deletion packages/solutions/app-tools/src/new/compat/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function getHookRunners(
prepare: async () => {
return hooks.onPrepare.call();
},
filedChange: async (params: {
fileChange: async (params: {
filename: string;
eventType: 'add' | 'change' | 'unlink';
isPrivate: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/solutions/app-tools/src/new/compat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function transformHookRunner(hookRunnerName: string) {
return 'addCommand';
case 'watchFiles':
return 'addWatchFiles';
case 'filedChange':
case 'fileChange':
return 'onFileChanged';
case 'beforeCreateCompiler':
return 'onBeforeCreateCompiler';
Expand Down
9 changes: 2 additions & 7 deletions packages/solutions/app-tools/src/utils/restart.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { ToRunners } from '@modern-js/core';
import { cli } from '@modern-js/plugin-v2/cli';
import {
chalk,
clearConsole,
getFullArgv,
logger,
program,
} from '@modern-js/utils';
import { chalk, clearConsole, getFullArgv, logger } from '@modern-js/utils';
import { program } from '@modern-js/utils/commander';
import type { AppToolsHooks } from '../types/hooks';

export async function restart(
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/plugin-v2/src/cli/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function initPluginAPI<Extends extends CLIPluginExtends>({
addCommand: hooks.addCommand.tap,

onPrepare: hooks.onPrepare.tap,
onWatchFiles: hooks.addWatchFiles.tap,
addWatchFiles: hooks.addWatchFiles.tap,
onFileChanged: hooks.onFileChanged.tap,
onBeforeRestart: hooks.onBeforeRestart.tap,
onBeforeCreateCompiler: hooks.onBeforeCreateCompiler.tap,
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/plugin-v2/src/types/cli/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
addCommand: PluginHookTap<AddCommandFn>;

onPrepare: PluginHookTap<OnPrepareFn>;
onWatchFiles: PluginHookTap<AddWatchFilesFn>;
addWatchFiles: PluginHookTap<AddWatchFilesFn>;
onFileChanged: PluginHookTap<OnFileChangedFn>;
onBeforeRestart: PluginHookTap<OnBeforeRestartFn>;
onBeforeCreateCompiler: PluginHookTap<OnBeforeCreateCompilerFn>;
Expand Down

0 comments on commit b0b8847

Please sign in to comment.