How to use the tiny-lr function in tiny-lr

To help you get started, we’ve selected a few tiny-lr 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 davewasmer / docify / lib / server.js View on Github external
export default function docify(options = {}) {
  let port = options.port || 3000;
  let docsPath = options.src || 'docs';
  let pkgPath = options.pkg || process.cwd();
  let themePath = options.theme
              || fs.existsSync('docs/theme') && 'docs/theme'
              || path.join(__dirname, '../themes/minimal');

  let builder = new broccoli.Builder(docsTree({ docsPath, pkgPath, themePath }));
  let server = broccoli.server.serve(builder, { host: 'localhost', port });

  // Start a livereload server
  let lrserver = tinylr();
  lrserver.listen(35729, () => {
    setTimeout(() => {
      // Trigger a reload on first start
      lrserver.changed({ body: { files: [ 'livereload files' ] } });
    }, 1000);
  });

  // Notify it on changes
  server.watcher.on('change', function() {
    lrserver.changed({ body: { files: [ 'livereload files' ] } });
  });

}
github jordanlaforest / drawgame / server / routes / static.js View on Github external
export default function(app) {
  app.use( express.static('public') );
  let b;
  if(app.get('env') === 'development') {
    tinylr().listen(35729);

    b = browserify({
      cache: {},
      packageCache: {},
      plugin: [watchify]
    });

    b.on('update', (ids) => {
      changedIds = ids;
      b.bundle(bundle);
    });
  }else{
    b = browserify({
      cache: {},
      packageCache: {}
    });
github FWeinb / metalsmith-watch / src / livereload.es View on Github external
export default function livereloadServer(options, log) {
  if(options === true) {
    options = {port: 35729}
  }
  else if(typeof options === "number") {
    options = {port: options}
  }

  const server = tinylr(options)

  server.on("error", function(err) {
    if(err.code === "EADDRINUSE") {
      log(color.red("Port " + options.port + " is already in use by another process."))
    }
    else {
      log(color.red(err))
    }

    throw err
  })

  server.listen(options.port, function(err) {
    if(err) {
      return log(color.red(err))
    }
github vtex / toolbelt / src / lib / watch.js View on Github external
.once('listening', () => {
        testPort.close();
        this.lr = tinylr();
        return this.lr.listen(port);
      })
      .listen(port);
github Rob-Leggett / angular_websockets_security / client / gulpfile.babel.js View on Github external
import util from "gulp-util";
import dateFormat from "date-format";
import path from "path";
import express from "express";
import morgan from "morgan";
import minimatch from "minimatch";
import http from "http";
import httpProxy from "http-proxy";
import tinyLiveReload from "tiny-lr";
import connectLiveReload from "connect-livereload";
import eventStream from "event-stream";
import yargs from "yargs";

const argv = yargs.argv;
const timestamp = dateFormat(argv['timestamp-format'] || process.env['GULP_TIMESTAMP_FORMAT'] || 'yyyyMMddhhmmss');
const liveReload = tinyLiveReload();

const project = require('./package.json');

function proxy(logPrefix, options, proxyPort) {
    let httpServer = http.createServer((req, res) => {
        let option = options.find((option) => {
            return (minimatch(req.url, option.pattern))
        });

        option.proxy.web(req, res);
    });

    httpServer.on('upgrade', (req, socket, head) => {
        let option = options.find((option) => {
            return (minimatch(req.url, option.pattern))
        });

tiny-lr

Tiny LiveReload server, background-friendly

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis