@istanbul/app
Version:
App package of istanbul framework
26 lines (25 loc) • 837 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.listenPlatformEvents = void 0;
const app_events_1 = require("../events/app.events");
const plugins_1 = require("../plugins");
const listenPlatformEvents = (plugins) => {
const publishEvent = (event) => {
app_events_1.appFinishedEvent.publish(event);
};
const closePlugins = () => {
for (const plugin of plugins.values()) {
if ((0, plugins_1.isCloseable)(plugin)) {
plugin.close();
}
}
};
["SIGBREAK", "SIGHUP", "SIGTERM", "SIGINT", "SIGBREAK"].forEach((signal) => {
process.on(signal, () => {
publishEvent(signal);
closePlugins();
process.exit(0);
});
});
};
exports.listenPlatformEvents = listenPlatformEvents;