MCPcopy Index your code
hub / github.com/browserify/watchify / watchify

Function watchify

index.js:12–165  ·  view source on GitHub ↗
(b, opts)

Source from the content-addressed store, hash-verified

10};
11
12function watchify (b, opts) {
13 if (!opts) opts = {};
14 var cache = b._options.cache;
15 var pkgcache = b._options.packageCache;
16 var delay = typeof opts.delay === 'number' ? opts.delay : 100;
17 var changingDeps = {};
18 var pending = false;
19 var updating = false;
20
21 var wopts = {persistent: true};
22 if (opts.ignoreWatch) {
23 var ignored = opts.ignoreWatch !== true
24 ? opts.ignoreWatch
25 : '**/node_modules/**';
26 }
27 if (opts.poll || typeof opts.poll === 'number') {
28 wopts.usePolling = true;
29 wopts.interval = opts.poll !== true
30 ? opts.poll
31 : undefined;
32 }
33
34 if (cache) {
35 b.on('reset', collect);
36 collect();
37 }
38
39 function collect () {
40 b.pipeline.get('deps').push(through.obj(function(row, enc, next) {
41 var file = row.expose ? b._expose[row.id] : row.file;
42 cache[file] = {
43 source: row.source,
44 deps: xtend(row.deps)
45 };
46 this.push(row);
47 next();
48 }));
49 }
50
51 b.on('file', function (file) {
52 watchFile(file);
53 });
54
55 b.on('package', function (pkg) {
56 var file = path.join(pkg.__dirname, 'package.json');
57 watchFile(file);
58 if (pkgcache) pkgcache[file] = pkg;
59 });
60
61 b.on('reset', reset);
62 reset();
63
64 function reset () {
65 var time = null;
66 var bytes = 0;
67 b.pipeline.get('record').on('end', function () {
68 time = Date.now();
69 });

Callers 10

expose.jsFile · 0.85
api.jsFile · 0.85
errors.jsFile · 0.85
api_brfs.jsFile · 0.85
args.jsFile · 0.85

Calls 3

collectFunction · 0.85
watchFileFunction · 0.85
resetFunction · 0.85

Tested by

no test coverage detected