npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boomer

v1.5.6

Published

Watch+livereload+express|connect in a nice wrapper

Downloads

19

Readme

Boomer

Ok what

Boomer cuts down on your task configuration. It is essentially a wrapper for grunt-contrib-connect and grunt-contrib-watch. You can also use an express app on top of it, that gives you a little more flexibility.

Show me

Excerpt from the test case.

var boomer = require("../boomer")

module.exports = function ( grunt ){

  boomer(grunt, "boomer-connect")
    .connect({
      hostname: "*",
      base: "test/"
    })
    .lr({
      html: "test/*.html"
    })
    .watch({
      options: {
        spawn: false,
        interrupt: true
      },
      html: {
        files: ["test/*.html"],
        tasks: ["lr:html"]
      }
    })
}

boomer is a function, you should call it with a grunt instance and an optional task name.

Note: by default boomer registers under the "default" grunt task.

Here's an express example (also from the tests):

var path = require("path")

var boomer = require("../boomer")

var express = require("express")
var app = express()

module.exports = function ( grunt ){

  boomer(grunt, "boomer-express")
    .express(app, function(  ){
      app.use(express.static(path.join(process.cwd(), "test")))
    })
    .lr({
      html: "test/*.html"
    })
    .watch({
      options: {
        spawn: false,
        interrupt: true
      },
      html: {
        files: ["test/*.html"],
        tasks: ["lr:html"]
      }
    })
}

What is what

.connect(options)

options - Object

Simple: it gets passed to the connect task as follows:

grunt.config("connect.boomer.options", options)

.express(app, setup)

app - Function

Like this:

var app = express()

setup - Function [Optional]

A function called when the task is run. Use it to setup your app here.

You should slate calling methods like .use() on the app, because boomer dynamically assigns a free port to the server when the task is run.

In order for the live reloading to work, your app initialization must come after the live reload script.

Use the setup callback to do that.

.watch(options)

options - Object

Gets passed directly to the watch task like this:

for( var name in options ){
  grunt.config("watch."+name, options[name])
}

.lr(options)

options - Object

Boomer registers a helper task called lr. It has a single boolean option called refresh. If set to true, only the first file will be posted to the lr server. It's useful when you want to monitor files that would always reload the whole page (like .js, .html), so only one will be sent.


.lr({
  js: {
    options: {refresh: true},
    src: "public/script/**/*.js"
  },
  img: "public/image/**/*.{jpe?g,png,gif,svg}"
})

It posts changed files to the livereload server so your browser can refresh.

It does this:

for( var name in options ){
  grunt.config("lr."+name, options[name])
}

.started(callback)

callback - Function(options)

Called when the server is started.

options.host The host the server is running on. (Usually your local IP) options.port The server port. options.livereload The livereload port.

Usage

Check the source, it's really straightforward.

Use it like this:

// I want these files posted to the browser
.lr({
  html: "test/*.html"
})
.watch({
  options: {
    spawn: false,
    interrupt: true
  },
  html: {
    // when these files change
    files: ["test/*.html"],
    // call the lr task
    tasks: ["lr:html"]
  }
})

That's it! MIT. Happy coding!