Sha256: f2bb0cac03a27f9c9e4296f07918f4f914bdc491bc4e2f2158f15038c790b88d
Contents?: true
Size: 1.43 KB
Versions: 21
Compression:
Stored size: 1.43 KB
Contents
const chokidar = require('chokidar'); const { verbose } = require('../utils'); const FingerprintQueue = require('./fingerprintQueue'); class FingerprintWatchCommand { constructor(directory) { this.directory = directory; this.print = true; this.numProcessed = 0; } execute() { if (verbose()) { console.warn(`Watching appmaps in ${this.directory}`); } this.fpQueue = new FingerprintQueue(); this.fpQueue.setCounterFn(() => { this.numProcessed += 1; }); this.fpQueue.process(); this.watcher = chokidar.watch(`${this.directory}/**/*.appmap.json`, { ignoreInitial: true, }); this.watcher .on('add', this.added.bind(this)) .on('change', this.changed.bind(this)) .on('unlink', this.removed.bind(this)); } close() { this.watcher.close(); this.watcher = null; } added(file) { if (verbose()) { console.warn(`AppMap added: ${file}`); } this.enqueue(file); } changed(file) { if (verbose()) { console.warn(`AppMap changed: ${file}`); } this.enqueue(file); } // eslint-disable-next-line class-methods-use-this removed(file) { console.warn(`TODO: AppMap removed: ${file}`); } enqueue(file) { // This shouldn't be necessary, but it's passing through the wrong file names. if (!file.includes('.appmap.json')) { return; } this.fpQueue.push(file); } } module.exports = FingerprintWatchCommand;
Version data entries
21 entries across 21 versions & 1 rubygems