0.7.0 • Published 7 years ago

livereload-xl v0.7.0

Weekly downloads
3
License
-
Repository
github
Last release
7 years ago

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);
0.7.0

7 years ago