livereload-xl

0.7.0 • Public • Published

livereload-xl

This is a modified version of the package node-livereload. It adds the ability to add a list of files and fire a callback when the files where changed.

There are no default watch options in this codebase.

Example:

const path = require('path');
const liveReload = require('livereload-xl');

const root = path.resolve('~/test');

const files = [
	path.join(root, '**/*.md'),
	path.join(root, 'specificScript.js')
];

const liveReloadServer = liveReload.createServer({
	port: liveReloadPort
});

const handleChanges = changedFile => {
	files.forEach(filePattern => {
		const match = minimatch(changedFile, filePattern, {
			matchBase: true,
			dot: true
		});

		if (match) {
			const shortPattern = path.relative(root, filePattern);
			console.log(`Watched file change: ${changedFile} matched: ${shortPattern}`);

			liveReloadServer.refresh(changedFile);
		}
	});
};

liveReloadServer.watch(watchList, handleChanges);

/livereload-xl/

    Package Sidebar

    Install

    npm i livereload-xl

    Weekly Downloads

    1

    Version

    0.7.0

    License

    none

    Last publish

    Collaborators

    • f1lt3r