fs-util

Incremental utilities for NodeJS File System API.

Incremental utilities for NodeJS File System API.

FS Tree Watcher

Provides the ability to watch an entire tree of folders and files.

  • Events:
  • watch
  • unwatch
  • create
  • change
  • delete
fsu = require 'fs-util'
watcher = fsu.watch 'desired/path'/.coffee$/m
watcher.on 'watch'(f)-> console.log 'WATCHED ' + [f.typef.location]
watcher.on 'unwatch'(f)-> console.log 'UNWATCHED ' + [f.typef.location]
watcher.on 'create'(f)-> console.log 'CREATED ' + [f.typef.location]
watcher.on 'change'(f)-> console.log 'CHANGED ' + [f.typef.location]
watcher.on 'delete'(f)-> console.log 'DELETED ' + [f.typef.location]

All callbacks receives one argument which is the related item to the event.

It has the following properties:

Fullpath location of the item.

Item type, can be dir or file.

Last stat of the file, it's an instance of fs.Stats.

Current stat of the file, it's an instance of fs.Stats.

The complete tree of subitems (files and folders) under that point.

  • Applies only when item.type is folder

Installing

npm install fs-util
cd fs-util && npm install
make build
make test

TODO

List of TODO features besides the current [FS Tree Watcher].watch:

  • mkdir [-p]
  • rm [-r] [-f]
  • search
  • cp [-r]
  • mv

Note: There are also some tests to be finished and tested across different platforms, such as Osx, Linux and Windows.