New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browser-sync-close-hook

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-sync-close-hook

Closes Browser Tabs which are connected to browserSync once browserSync disconnects (when stopping gulp for example)

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

browser-sync-close-hook

Closes Browser Tabs which are connected to browserSync once browserSync disconnects (when stopping gulp for example).

Install

> npm install browser-sync-close-hook --save-dev

Usage in gulpfile.js

const autoClose = require('browser-sync-close-hook');

gulp.task('serve', ['watch'], () => {
  browserSync.use({
    plugin() {},
    hooks: {
      'client:js': autoClose, // <-- important part
    },
  });

  browserSync({
    ui: false,
    notify: false,
    server: {
      baseDir: './public',
      middleware: [historyApiFallback()],
    },
  });
});

Source

The only thing this module does is exporting a function string which useses the clients browsers window.close function to close the tab.

module.exports = "___browserSync___.socket.on('disconnect', window.close.bind(window));";

Credits

for providing the original solutions:

  • https://gist.github.com/timthez
  • https://gist.github.com/shakyShane/3d5ec6685e07fd3227ba

for the discussion which let to solving the issue of too many open tabs:

FAQs

Package last updated on 27 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc