包详细信息

wiper

bitinn921MIT1.3.0

A command line tool that gaze at your file changes and do a tiny-lr when needed

watch, livereload

自述文件

wiper

npm version build status

A command line tool that watch file changes and do a livereload when needed (compatible with both node.js and io.js), and works over https.

Motivation

This allows us to use npm as our build tool instead of grunt or gulp.

Install

npm install wiper --save-dev or npm install -g wiper

Usage

In your package.json, add these lines.

{
    "scripts": {
        "watch": "DEBUG=wiper wiper -p 1234 -t 2000 -w \\*\\*/\\*.js,\\*\\*/\\*.css"
    }
}

Now try npm run watch, a livereload server will be running at localhost:1234 and watching updates to javascript/css files.

Options

  • -p port to listen on, default to 35729.
  • -t debounce timeout, default to 5000ms.
  • -w files to watch; note that you should use \* to prevent bash from expanding globs, as we want wiper to expand it instead, also see that we double escape \\* in package.json due to additional string escapes.
  • --cert=ssl.crt and --key=ssl.key to start livereload server on https, generate your self-signed certificate and import them into your CA trust store for this to work.

Integration

To integrate with your koa/express server, use modules like koa-livereload or connect-livereload.

// for http
app.use(livereload({
    port: 1234
}));

// for https
app.use(livereload({
    src: 'https://example.com:1234/livereload.js?snipver=1'
}));

Or manually insert this line onto your template.

<script src="http://localhost:1234/livereload.js?snipver=1"></script>

Now your browsers will be refreshed automatically when file change occurs. And see, no grunt or gulp needed, just good-old npm.

License

MIT

更新日志

Changelog

1.x release

v1.3.0 (master)

  • Feature: change from throttle to debounce to prevent duplicate event
  • Feature: add timeout parameter for debounce
  • Remove: un-used quiet parameter, we are quiet by default

v1.2.0

  • Workaround: throttle livereload (wait 5 seconds)

v1.1.1

  • Fix: wiper error should exit with code 1

v1.1.0

  • Feature: use chokidar instead of gaze
  • Feature: added https support

v1.0.3

  • Enhance: output message now use debug module
  • Enhance: io.js test

v1.0.2

  • Fix: error handling
  • Fix: page refresh

v1.0.1

  • Fix: documents and tests

v1.0.0

  • Major: public release