customize-watch
A file watcher for customize
customize-watch
is a file watcher for customize
It attaches watchers (using chokidar) to
the files and directories that are relevant for computing a result with customize
.
If files are added, removed or changed the result will be recomputed.
Installation
npm install customize-watch
Usage
The following example is almost identical to the
"merging another configuration"-example of the customize
-module.
var customize = require('customize-watch')
customize()
.registerEngine('files', require('./engine-concat-files'))
.merge({
files: 'dir1'
})
.merge({
files: 'dir2'
})
.watch()
.on('update', function (result) {
console.log('result', result.files)
})
It will generate the same output, but every time the files in dir1
and dir2
are changed,
removed or added, the output will be recomputed. The update
-event will be sent with the result
as argument, every time the computation has finished.
API-reference
Recustomize
Kind: global class
new Recustomize(builder)
Recustomize has the same interface as Customize, but instead of storing
the current configuration-state, it stores a function that computes the state.
The only difference is the watch()-method. It can be
used to emit an event every time one of the input files is added, removed or changed.
Param | Type | Description |
---|
builder | function | a builder function for a Customize object |
recustomize.merge
Wrapped function. See customize for details
Kind: instance property of Recustomize
Api: private
recustomize.registerEngine
Wrapped function. See customize for details
Kind: instance property of Recustomize
Api: private
recustomize.load
Wrapped function. See customize for details
Kind: instance property of Recustomize
Api: private
recustomize.build() ⇒ Promise.<object>
Return the configuation object
Kind: instance method of Recustomize
Api: private
recustomize.watched() ⇒ Promise.<object.<Array.<string>>>
Return a list of files and directories that need to be watched
in watch-mode.
Kind: instance method of Recustomize
Returns: Promise.<object.<Array.<string>>>
- a list of paths to files or directories for each engine
Api: private
recustomize.watch() ⇒ EventEmitter
Register file-watchers for all relevant files.
Rebuild the config and run the appropriate engine, whenever
a file has changed.
Kind: instance method of Recustomize
recustomize.run() ⇒ object
Wraps the run(...)-method of the customize object, rebuilding the whole configuration
before running.
Kind: instance method of Recustomize
Api: private
Recustomize~wrap(fnName) ⇒ function
Wrap the method of a Customize object such that
instead of the new Customize object, new Recustomize object
with the appropriate builder-function is returned
Kind: inner method of Recustomize
Api: private
License
customize-watch
is published under the MIT-license.
See LICENSE.md for details.
Release-Notes
For release notes, see CHANGELOG.md
Contributing guidelines
See CONTRIBUTING.md.