How to use exit-hook - 7 common examples

To help you get started, we’ve selected a few exit-hook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github azproduction / node-mc / server / lib / tui-react / render.js View on Github external
export default function render(rootComponent, stdio) {
    var mount = new TuiRootMount(rootComponent, stdio);
    exitHook(mount.componentWillUnmount.bind(mount));
    mount.componentDidMount();

    var events = new TuiEvents(stdio);
    exitHook(events.componentWillUnmount.bind(events));
    events.componentDidMount();

    // Pipe events to mount
    events.on('event', mount.handleEvent.bind(mount));
}
github azproduction / node-mc / server / node-mc.js View on Github external
return new Promise((resolve) => {
            var webpackDevServer = require.resolve('.bin/webpack-dev-server');
            var args = '--config webpack.config.dev.js --hot --no-info --colors --port 2992 --inline';
            var hotReload = spawn(webpackDevServer, args.split(' '), {
                cwd: path.join(__dirname, '..'),
                env: this.process.env,
                stdio: [
                    'pipe',
                    'pipe',
                    this.process.stderr
                ]
            });
            exitHook(hotReload.kill.bind(hotReload));
            hotReload.stdout.once('data', resolve);
        });
    }
github ewnd9 / badtaste / src / index.js View on Github external
.then(() => {
    const screen = tui();
    const main = new MainController(screen);

    const player = cli.flags.player === 'mpd' ? new MpdPlayer() : new NodePlayer();
    player.setOnNextSongCallback(() => store.dispatch(moveNext()));

    exitHook(player.killPlayer.bind(player));

    storage.on(PAUSE, () => player.pause());
    storage.on(PLAY, url => player.play(url));

    screen.key(['C-f'], () => storage.emit(SEARCH_VK));
    screen.key(['f'], () => storage.emit(LOCAL_SEARCH));
    screen.key(['space'], () => storage.emit(PAUSE));
    screen.key(['x'], () => storage.emit(ADD_TO_PROFILE));
    screen.key(['m', 'ь'], () => storage.emit(SWITCH_PANE));
    screen.key(['d', 'в'], () => storage.emit(MOVE_TO_PLAYING));

    screen.key(['left'], () => storage.emit(FOCUS_LEFT_PANE));
    screen.key(['right'], () => storage.emit(FOCUS_RIGHT_PANE));

    screen.key(['/', '?', '.', ','], () => storage.emit(SHOW_HELP));
github elastic / kibana / packages / kbn-dev-utils / src / run / run.ts View on Github external
};

  const doCleanup = () => {
    const tasks = cleanupTasks.slice(0);
    cleanupTasks.length = 0;

    for (const task of tasks) {
      try {
        task();
      } catch (error) {
        handleErrorWithoutExit(error);
      }
    }
  };

  const unhookExit: CleanupTask = exitHook(doCleanup);
  const cleanupTasks: CleanupTask[] = [unhookExit];

  try {
    if (!allowUnexpected && flags.unexpected.length) {
      throw createFlagError(`Unknown flag(s) "${flags.unexpected.join('", "')}"`);
    }

    try {
      await fn({
        log,
        flags,
        addCleanupTask: (task: CleanupTask) => cleanupTasks.push(task),
      });
    } finally {
      doCleanup();
    }
github elastic / kibana / packages / kbn-dev-utils / src / proc_runner / proc_runner.ts View on Github external
constructor(private log: ToolingLog) {
    this.signalUnsubscribe = exitHook(() => {
      this.teardown().catch(error => {
        log.error(`ProcRunner teardown error: ${error.stack}`);
      });
    });
  }
github ewnd9 / media-center / src / players / base.js View on Github external
function Player(trakt) {
  this.status = STOPPED;
  this.trakt = trakt;

  exitHook(() => this.stop());
}

exit-hook

Run some code when the process exits

MIT
Latest version published 8 months ago

Package Health Score

78 / 100
Full package analysis

Popular exit-hook functions