How to use capture-exit - 7 common examples

To help you get started, we’ve selected a few capture-exit 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 dollarshaveclub / ember-cli-anybar / index.js View on Github external
} else {
  // Open AnyBar
  exec('open --hide --background -a AnyBar', (error, stdout, stderror) => {
    if (error) {
      console.error(`
      You have the ember-cli-anybar addon installed but have
      not yet installed the AnyBar application. Please run:

        brew cask install anybar
      `)
    }
  })

  // Back to white on exit
  captureExit.captureExit()
  captureExit.onExit(function resetAnyBar () {
    clearInterval(pulser)
    return anybar('white')
  })

  module.exports = {
    name: 'ember-cli-anybar',

    preBuild () {
      pulse()
    },

    buildError: function buildError () {
      clearInterval(pulser)
      anybar('red')
    },
github amasad / sane / src / watchman_client.js View on Github external
captureExit.captureExit();

    // define/clear some local state. The properties will be initialized
    // in _handleClientAndCheck(). This is also called again in _onEnd when
    // trying to reestablish connection to watchman.
    this._clearLocalVars();

    this._watchmanBinaryPath = watchmanBinaryPath;

    this._backoffTimes = this._setupBackoffTimes();

    this._clientListeners = null; // direct listeners from here to watchman.Client.

    // Define a handler for if somehow the Node process gets interrupted. We need to
    // close down the watchman.Client, if we have one.
    captureExit.onExit(() => this._clearLocalVars());
  }
github amasad / sane / src / watchman_client.js View on Github external
constructor(watchmanBinaryPath) {
    captureExit.captureExit();

    // define/clear some local state. The properties will be initialized
    // in _handleClientAndCheck(). This is also called again in _onEnd when
    // trying to reestablish connection to watchman.
    this._clearLocalVars();

    this._watchmanBinaryPath = watchmanBinaryPath;

    this._backoffTimes = this._setupBackoffTimes();

    this._clientListeners = null; // direct listeners from here to watchman.Client.

    // Define a handler for if somehow the Node process gets interrupted. We need to
    // close down the watchman.Client, if we have one.
    captureExit.onExit(() => this._clearLocalVars());
  }
github adopted-ember-addons / ember-electron / lib / models / assembler.js View on Github external
trapSignals() {
    this._boundOnSIGINT = this.onSIGINT.bind(this);
    this._boundOnSIGTERM = this.onSIGTERM.bind(this);
    this._boundOnMessage = this.onMessage.bind(this);
    this._boundCleanup = this.cleanup.bind(this);

    process.on('SIGINT', this._boundOnSIGINT);
    process.on('SIGTERM', this._boundOnSIGTERM);
    process.on('message', this._boundOnMessage);
    exit.onExit(this._boundCleanup);

    if (/^win/.test(process.platform)) {
      this.trapWindowsSignals();
    }
  }
github ember-cli / ember-cli / lib / utilities / will-interrupt-process.js View on Github external
addHandler(cb) {
    if (!_process) {
      throw new Error('process is not captured');
    }

    let index = handlers.indexOf(cb);
    if (index > -1) {
      return;
    }

    if (handlers.length === 0) {
      setupSignalsTrap();
    }

    handlers.push(cb);
    captureExit.onExit(cb);
  },
github ember-cli / ember-cli / lib / utilities / will-interrupt-process.js View on Github external
removeHandler(cb) {
    let index = handlers.indexOf(cb);
    if (index < 0) {
      return;
    }

    handlers.splice(index, 1);
    captureExit.offExit(cb);

    if (handlers.length === 0) {
      teardownSignalsTrap();
    }
  },
};
github adopted-ember-addons / ember-electron / lib / models / assembler.js View on Github external
_cleanupSignals() {
    process.removeListener('SIGINT', this._boundOnSIGINT);
    process.removeListener('SIGTERM', this._boundOnSIGTERM);
    process.removeListener('message', this._boundOnMessage);
    exit.offExit(this._boundCleanup);

    if (/^win/.test(process.platform)) {
      this._cleanupWindowsSignals();
    }
  }

capture-exit

safely cleanup in signal handlers

ISC
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis

Similar packages