Incremental utilities for NodeJS File System API.
Provides the ability to watch an entire tree of
fsu = require 'fs-util' watcher = fsu.watch [desired_path], [regex_pattern], [recursive_notifications]
The path to the
file you wanna watch.
The regex to filter only the files you wanna watch.
true notifications will be fired for all files. If you delete a
that has many
sub dirs and
delete events will be
dispatched for all the children
files as well.
false, only one event will be dispatched for the
dir that was actually
deleted. It can save you an overhead of events popping up when a
big ammount of
files is deleted.
fsu = require 'fs-util' watcher = fsu.watch 'desired/path', /.coffee$/m, true watcher.on 'watch', (f)-> console.log 'WATCHED ' + [f.type, f.location] watcher.on 'unwatch', (f)-> console.log 'UNWATCHED ' + [f.type, f.location] watcher.on 'create', (f)-> console.log 'CREATED ' + [f.type, f.location] watcher.on 'change', (f)-> console.log 'CHANGED ' + [f.type, f.location] watcher.on 'delete', (f)-> console.log 'DELETED ' + [f.type, f.location] watcher.close()
All callbacks receives only one argument which is the related
It has the following properties:
location of the item.
type, can be
Current stat of the file, it's an instance of fs.Stats.
tree of subitems (
dirs) under that point.
- Applies only when
Besides all the Event Emiter inherited methods, the
watcher class has one more:
When called, this method will forcely close all persistent watcher's process and
removes all previously added listeners. Every file and folder is
events will pop normally for them, and after that the instance becomes useless.
Provides functionalities such as
fsu = require 'fs-util' fsu.mkdirp [dir_path] fsu.touch [file_path], [encoding='utf-8'] fsu.copy [from_path], [to_path] fsu.find [path], [regex_pattern], [include_dirs] fsu.ls [path] fsu.rm_rm [path]
Absolute or relative
paths are accepted, you take care of your things.
file encoding when
Your search pattern, i.e.
true will include the
dirs in the search, otherwise only
Remembers that you need to install fs-util locally in order to use it as a LIB.
You will need to
require 'fs-util in you script, there's no reason to install
it globally with
fs-util won't work directly in the command line.
At least for now.
npm install fs-util
In order to contribute you will need to
clone and initialize the env.
git clone email@example.com:[username]/fs-util cd fs-util && npm install
src/*.coffee files to
Continuously building in
Running tests suite.