UNPKG

1.52 kBJavaScriptView Raw
1/*
2 * Copyright 2018 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13'use strict';
14
15/* eslint global-require: off */
16
17const yargsBuild = require('./yargs-build.js');
18const { getOrCreateLogger } = require('./log-common.js');
19
20module.exports = function build() {
21 let executor;
22 return {
23 set executor(value) {
24 executor = value;
25 },
26 command: 'build [files..]',
27 desc: 'Compile the template functions and build package',
28 builder: (yargs) => {
29 yargsBuild(yargs);
30 yargs.help();
31 },
32 handler: async (argv) => {
33 if (!executor) {
34 // eslint-disable-next-line global-require
35 const BuildCommand = require('./build.cmd'); // lazy load the handler to speed up execution time
36 executor = new BuildCommand(getOrCreateLogger(argv));
37 }
38
39 await executor
40 .withTargetDir(argv.target)
41 .withFiles(argv.files)
42 .withCustomPipeline(argv.customPipeline)
43 .run();
44 },
45 };
46};