amis-rpc-design/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tap-stop-to-terminate-workers.js

27 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tapStopToTerminateWorkers = void 0;
const infrastructure_logger_1 = require("../infrastructure-logger");
function tapStopToTerminateWorkers(compiler, getIssuesWorker, getDependenciesWorker, state) {
const { debug } = (0, infrastructure_logger_1.getInfrastructureLogger)(compiler);
const terminateWorkers = () => {
debug('Compiler is going to close - terminating workers...');
getIssuesWorker.terminate();
getDependenciesWorker.terminate();
};
compiler.hooks.watchClose.tap('ForkTsCheckerWebpackPlugin', () => {
terminateWorkers();
});
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', () => {
if (!state.watching) {
terminateWorkers();
}
});
compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', () => {
if (!state.watching) {
terminateWorkers();
}
});
}
exports.tapStopToTerminateWorkers = tapStopToTerminateWorkers;