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>

37 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.entriesEmitter = entriesEmitter; const tslib_1 = require("tslib"); const core_1 = require("@ng-doc/core"); const fast_glob_1 = require("fast-glob"); const minimatch_1 = require("minimatch"); const path_1 = tslib_1.__importDefault(require("path")); const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const helpers_1 = require("../../../helpers"); const builders_1 = require("../../builders"); const api_list_1 = require("../../builders/api-list"); const variables_1 = require("../../variables"); const watcher_1 = require("../watcher"); /** * * @param context */ function entriesEmitter(context) { const entries = (0, fast_glob_1.sync)([ (0, helpers_1.posix)(path_1.default.join(context.docsPath, variables_1.PAGE_PATTERN)), (0, helpers_1.posix)(path_1.default.join(context.docsPath, variables_1.API_PATTERN)), ]); return (0, watcher_1.watchFolder)(context.docsPath, 'create').pipe((0, operators_1.map)((events) => events.map((event) => event.path)), (0, operators_1.startWith)(entries), (0, operators_1.map)((events) => events .map((filePath) => { if ((0, minimatch_1.minimatch)(filePath, variables_1.PAGE_PATTERN)) { return (0, builders_1.pageBuilder)(context, path_1.default.resolve(filePath)); } if ((0, minimatch_1.minimatch)(filePath, variables_1.API_PATTERN)) { return (0, api_list_1.apiBuilder)(context, path_1.default.resolve(filePath)); } return null; }) .filter(core_1.isPresent)), (0, operators_1.filter)((builders) => builders.length > 0), (0, rxjs_1.mergeMap)((builders) => (0, rxjs_1.merge)(...builders))); } //# sourceMappingURL=entries-emitter.js.map