@plotdb/srcbuild 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/watch.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,6 +128,22 @@ When using shorthands like `srcbuild.lsp(...)`, you can also specify correspondi
|
|
|
128
128
|
common options will be overwritten by scoped options.
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
## Using custom builders
|
|
132
|
+
|
|
133
|
+
Send adapters to watcher from `getAdapter()` of each custom builders:
|
|
134
|
+
|
|
135
|
+
require! <[@plotdb/srcbuild/dist/watch @plotdb/srcbuild/dist/ext/pug]>
|
|
136
|
+
pugbuilder = new pug(...)
|
|
137
|
+
watcher = new watch({adapters: [pugbuilder.getAdapter]})
|
|
138
|
+
|
|
139
|
+
By default, watcher watches the current working directory. Change watcher behavior with following constructor options:
|
|
140
|
+
|
|
141
|
+
- `adapters`: array of adapters to use to handle file change events.
|
|
142
|
+
- `ignored`: array of glob strings to ignore when watching for changes. by default `[".git"]`.
|
|
143
|
+
- `root`: directory, or array of directories to watch. by default `["."]`.
|
|
144
|
+
- `logger`: optional. logger object with logging functions such as `info`, `warn` and `error`.
|
|
145
|
+
|
|
146
|
+
|
|
131
147
|
## ODB / On demand build
|
|
132
148
|
|
|
133
149
|
use `watch.demand(target-file)` to force rebuild by request. e.g.,
|
package/dist/watch.js
CHANGED
|
@@ -17,6 +17,9 @@ watch = function(opt){
|
|
|
17
17
|
ignored: opt.ignored || ['.git'],
|
|
18
18
|
ignoreInitial: true
|
|
19
19
|
};
|
|
20
|
+
this._root = opt.root ? Array.isArray(opt.root)
|
|
21
|
+
? opt.root
|
|
22
|
+
: [opt.root] : void 8;
|
|
20
23
|
this.log = opt.logger || aux.logger;
|
|
21
24
|
this.init();
|
|
22
25
|
return this;
|
|
@@ -31,7 +34,7 @@ watch.prototype = import$(Object.create(Object.prototype), {
|
|
|
31
34
|
},
|
|
32
35
|
init: function(){
|
|
33
36
|
var this$ = this;
|
|
34
|
-
this.watcher = chokidar.watch(['.'], this.chokidarCfg).on('add', function(it){
|
|
37
|
+
this.watcher = chokidar.watch(this._root || ['.'], this.chokidarCfg).on('add', function(it){
|
|
35
38
|
return this$.add(path.normalize(it));
|
|
36
39
|
}).on('change', function(it){
|
|
37
40
|
return this$.change(path.normalize(it));
|