UNPKG

1.21 kBJavaScriptView Raw
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.execute = void 0;
11const architect_1 = require("@angular-devkit/architect");
12const path_1 = require("path");
13const rxjs_1 = require("rxjs");
14const operators_1 = require("rxjs/operators");
15async function initialize(options, root) {
16 const packager = (await Promise.resolve().then(() => require('ng-packagr'))).ngPackagr();
17 packager.forProject(path_1.resolve(root, options.project));
18 if (options.tsConfig) {
19 packager.withTsConfig(path_1.resolve(root, options.tsConfig));
20 }
21 return packager;
22}
23/**
24 * @experimental Direct usage of this function is considered experimental.
25 */
26function execute(options, context) {
27 return rxjs_1.from(initialize(options, context.workspaceRoot)).pipe(operators_1.switchMap((packager) => (options.watch ? packager.watch() : packager.build())), operators_1.mapTo({ success: true }));
28}
29exports.execute = execute;
30exports.default = architect_1.createBuilder(execute);