UNPKG

alm

Version:

The best IDE for TypeScript

37 lines (36 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var flm = require("../workers/fileListing/fileListingMaster"); var fileModelCache = require("./fileModelCache"); var chokidar = require("chokidar"); /** * Our global dictionary */ var watchedEditorConfigFiles = Object.create(null); function watchEditorConfigIfNotAlreadyWatching(filePath) { if (watchedEditorConfigFiles[filePath]) return; watchedEditorConfigFiles[filePath] = true; var fsWatcher = chokidar.watch(filePath, { ignoreInitial: true }); fsWatcher.on('change', watchedEditorConfigChanged); } function start() { flm.filePathsCompleted.on(function (res) { // Make sure we watch any `.editorconfig` files res.filePaths .filter(function (fp) { return fp.filePath.endsWith('.editorconfig'); }) .map(function (fp) { return fp.filePath; }) .forEach(watchEditorConfigIfNotAlreadyWatching); }); flm.filePathsUpdated.on(function (res) { // Make sure we watch any `.editorconfig` files res.filePaths .filter(function (fp) { return fp.filePath.endsWith('.editorconfig'); }) .map(function (fp) { return fp.filePath; }) .forEach(watchEditorConfigIfNotAlreadyWatching); }); } exports.start = start; function watchedEditorConfigChanged() { fileModelCache.watchedEditorConfigChanged(); }