UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

29 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.watchFile = watchFile; const tslib_1 = require("tslib"); const core_1 = require("@ng-doc/core"); const path_1 = tslib_1.__importDefault(require("path")); const operators_1 = require("rxjs/operators"); const watch_1 = require("./watch"); /** * Function to watch a specific file for changes. * @param {string} filePath - The path of the file to watch. * @param type - The type of event to watch for. * @returns {Observable<watcher.Event>} - An Observable that emits an event whenever the file changes. */ function watchFile(filePath, type) { return (0, watch_1.watch)(filePath).pipe((0, operators_1.map)((events) => { return events.find((event) => { const isFolder = path_1.default.extname(event.path) === ''; if (event.type === type && isFolder && event.type === 'delete' && filePath.startsWith(event.path)) { return true; } return event.path === filePath && (!type || (0, core_1.asArray)(type).includes(event.type)); }); }), (0, operators_1.filter)(core_1.isPresent)); } //# sourceMappingURL=watch-file.js.map