Skip to content

Commit

Permalink
fix(cli-service) 修复 ServeHook after 阶段未执行问题
Browse files Browse the repository at this point in the history
  • Loading branch information
muxiangqiu committed Dec 8, 2023
1 parent c71cde1 commit 74a7d1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change

## 2.52.4

- fix(cli-service) 修复 ServeHook after 阶段未执行问题

## 2.52.3

- feat(web) 支持 ServerAware 扩展接口,方便扩展 Web Socket 服务
Expand Down
7 changes: 6 additions & 1 deletion dev-packages/cli-service/src/hooks/serve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as webpack from 'webpack';
import { CliContext } from '@malagu/cli-common/lib/context/context-protocol';
import { CommandType, CommandUtil } from '@malagu/cli-common/lib/utils/command-util';
import { CommandStage, CommandType, CommandUtil } from '@malagu/cli-common/lib/utils/command-util';
import { ServiceContextUtils } from '../context/context-protocol';
import { startDevServer } from './start-dev-server';
import * as https from 'https';
import * as http from 'http';
import { HookExecutor, HookStage } from '@malagu/cli-common/lib/hook/hook-executor';

export type Callback = (server: http.Server | https.Server, app: Express.Application,
compiler: webpack.Compiler, entryContextProvider: () => Promise<any>) => Promise<void>;
Expand All @@ -26,6 +27,10 @@ export default async (ctx: CliContext) => {
context.app = app;
context.compiler = compiler;
context.entryContextProvider = entryContextProvider;
compiler.hooks.done.tap('ServeAfter', async () => {
new HookExecutor().executeServeHooks(context, HookStage.after);
await CommandUtil.executeCommand(context, CommandType.ServeCommand, CommandStage.after);
});
});
}
};

0 comments on commit 74a7d1f

Please sign in to comment.