Skip to content

necccc/lnwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lnwatch

Build Status

Small utility for node, to watch symlink changes.


Usage

var lnw = require('../lnwatch.js')

lnw.on('change', function (data) {
	console.log('LINK CHANGED', data);
})

lnw.add([
	'./foo',
	'./qux',  // nonexistent link, ignored
	'./bar'
])

Methods

lnwatch.add(links)

Add links to watch, can be a single link path string, or several in an array. Nonexistent links will be ignored.

lnwatch.remove([links])

Remove watched links, can be a single link path string, or several in an array. Nonexistent links will be ignored.

lnwatch.removeAll()

Remove all watched links.

Events

lnw.on('change', callback)

Fired when one of the watched link changes target. Receives data about what changed:

  • which link,
  • from what target,
  • to which target

Example:


lnw.on('change', function (data) {
	console.log(data);
})

/* 

outputs:

{ 
  link: '/Users/nec/github/lnwatch/tests/bar',
  from: '/Users/nec/github/lnwatch/tests/two',
  to: '/Users/nec/github/lnwatch/tests/three' 
}

*/

About

watch a symlink if it changes

Resources

License

Stars

Watchers

Forks

Packages

No packages published