source: trip-planner-front/node_modules/@angular-devkit/core/node/experimental/jobs/job-registry.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.NodeModuleJobRegistry = void 0;
11const rxjs_1 = require("rxjs");
12const src_1 = require("../../../src");
13class NodeModuleJobRegistry {
14 _resolve(name) {
15 try {
16 return require.resolve(name);
17 }
18 catch (e) {
19 if (e.code === 'MODULE_NOT_FOUND') {
20 return null;
21 }
22 throw e;
23 }
24 }
25 /**
26 * Get a job description for a named job.
27 *
28 * @param name The name of the job.
29 * @returns A description, or null if the job is not registered.
30 */
31 get(name) {
32 const [moduleName, exportName] = name.split(/#/, 2);
33 const resolvedPath = this._resolve(moduleName);
34 if (!resolvedPath) {
35 return rxjs_1.of(null);
36 }
37 const pkg = require(resolvedPath);
38 const handler = pkg[exportName || 'default'];
39 if (!handler) {
40 return rxjs_1.of(null);
41 }
42 function _getValue(...fields) {
43 return fields.find((x) => src_1.schema.isJsonSchema(x)) || true;
44 }
45 const argument = _getValue(pkg.argument, handler.argument);
46 const input = _getValue(pkg.input, handler.input);
47 const output = _getValue(pkg.output, handler.output);
48 const channels = _getValue(pkg.channels, handler.channels);
49 return rxjs_1.of(Object.assign(handler.bind(undefined), {
50 jobDescription: {
51 argument,
52 input,
53 output,
54 channels,
55 },
56 }));
57 }
58}
59exports.NodeModuleJobRegistry = NodeModuleJobRegistry;
Note: See TracBrowser for help on using the repository browser.