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

Version Path
appmap-0.72.2 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.72.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.72.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.71.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.70.2 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.70.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.70.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.69.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.68.2 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.68.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.68.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.67.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.67.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.66.2 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.66.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.66.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.65.1 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.65.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.64.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js
appmap-0.63.0 ./node_modules/@appland/appmap/src/fingerprint/fingerprintWatchCommand.js