UNPKG

alm

Version:

The best IDE for TypeScript

28 lines (27 loc) 800 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * There are cases when we have to exit the server * but don't want to leave a client hanging * so we tell them about it. e.g. * - ctrl + c * - globbing failure */ var events_1 = require("../common/events"); var serverExit = new events_1.TypedEvent(); /** * We want subscribers first * and then exit process * always in that order */ exports.onServerExit = function (cb) { return serverExit.on(cb); }; exports.emitServerExit = function () { serverExit.emit({}); process.exit(); }; /** * http://stackoverflow.com/a/14032965/390330 * However the network stack only works if user does ctrl+c. In other cases we cannot even cast. */ // catches ctrl+c event process.on('SIGINT', exports.emitServerExit);