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

glob-lr

v0.1.1

Published

A livereload cli tool that eats globs.

Downloads

26

Readme

glob-lr

npm npm npm

A livereload cli tool that eats globs.

$ glob-lr 'www/**' '!www/vendor/**'
LiveReload listening on port 35729
LiveReload added 10 files

I guess you can use it in Node too if you want:

var globlr = require('glob-lr');
var lr = globlr(['www/**', '!www/vendor/**'], opts);
// Now lr.watcher is a chokidar instance, lr.server is a
// listening tiny-lr server, and lr.shutdown() will close everything.

The globs are passed as an array to chokidar. Make sure they are quoted when using the cli. Folders named "node_modules", ".git", ".svn", or ".hg" and files within are ignored by default. tiny-lr is the livereload server which serves the livereload snippet and notifies the client.

Install using npm globally: $ npm install -g glob-lr

Or in your project's package.json: $ npm install --save-dev glob-lr

Recipes

Watch all files of any depth within www/ but not any within www/vendor/, wait 5 seconds before reloading on changes:

glob-lr 'www/**' '!www/vendor/**' --delay 5000

Watch files of any depth within directories named "www" at any depth from the current working directory but exclude directories named "vendor" at any depth:

glob-lr '**/www/**' '!**/vendor/**'

Watch javascript files within static/ except for files with names beginning with "foo" but do watch "foobaz". Also, ignore jonathan.

glob-lr 'static/*.js' '!static/foo!(baz).js' '!static/jonathan.js'

Watch only css, html, and js files within a client directory as part of a npm watch script:

{
    "scripts": {
        "watch": "run-p watch:*",
        "watch:livereload": "glob-lr 'client/**/*.{css,js,html}'",
        "watch:server": "nodemon server/"
    },
    "devDependencies": {
        "npm-run-all": "^2.2.0",
        "nodemon": "^1.9.2",
        "glob-lr": "^0.1.0"
    }
}

Enabling LiveReload

You'll either need the browser extension OR you can embed the snippet into your HTML.

Options

Cli parameters are parsed with minimist and merged with the options object which is passed to chokidar and tiny-lr. For example --followSymlinks false will configure chokidar's followSymblinks option. Chokidar and tiny-lr have a number of their own options in addition to glob-lr's defaults:

port: (default 35729) (shorthand -p) The livereload port your livereload client script or browser extension tries to connect to

delay: (defualt 200) (shorthand -d) Milliseconds to debounce file changes before telling tiny-lr to notify the client

quiet: (default false) (shorthand -q) Suppress console output (unless you are debugging with DEBUG=glob-lr)

noDefaultGlobs: (default false) Files within directories named node_modules, .git, .svn, and .hg are ignored by default. Setting this will disable ignoring them

Node API

var lr = globlr(globs, opts)

Globs is an array of glob strings or a single glob string which will be made an array. The default globs will be added to the end of this array and it will then be passed to chokidar.

lr.watcher

The instance of chokidar so you have access to its API directly.

lr.server

The instance of tiny-lr so you have access to its API directly.

lr.shutdown([err])

Will cancel any debounced notifications and call the close methods of the watcher and server to allow the process to end.

lr.fileCount

Integer, the number of files being watched at the moment.

License

MIT