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 | ;
|
14 |
|
15 | const { getOrCreateLogger } = require('./log-common.js');
|
16 |
|
17 | module.exports = function demo() {
|
18 | let executor;
|
19 |
|
20 | return {
|
21 | set executor(value) {
|
22 | executor = value;
|
23 | },
|
24 | command: 'clean',
|
25 | desc: 'Remove generated files and caches.',
|
26 | builder: (yargs) => {
|
27 | yargs
|
28 | .option('target', {
|
29 | alias: 'o',
|
30 | default: '.hlx/build',
|
31 | describe: 'Target directory for compiled JS',
|
32 | });
|
33 | },
|
34 | handler: async (argv) => {
|
35 | if (!executor) {
|
36 | // eslint-disable-next-line global-require
|
37 | const CleanCommand = require('./clean.cmd'); // lazy load the handler to speed up execution time
|
38 | executor = new CleanCommand(getOrCreateLogger(argv));
|
39 | }
|
40 |
|
41 | await executor
|
42 | .withTargetDir(argv.target)
|
43 | .run();
|
44 | },
|
45 | };
|
46 | };
|