1 | /*
|
2 | * Copyright 2019 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 | /* eslint global-require: off */
|
14 |
|
15 | const { getOrCreateLogger } = require('./log-common.js');
|
16 |
|
17 | module.exports = function hack() {
|
18 | let executor;
|
19 | return {
|
20 | set executor(value) {
|
21 | executor = value;
|
22 | },
|
23 | command: 'hack [hackathon]',
|
24 | builder: (yargs) => {
|
25 | yargs
|
26 | .positional('hackathon', {
|
27 | describe: 'The hackathon to attend',
|
28 | default: '',
|
29 | array: false,
|
30 | type: 'string',
|
31 | })
|
32 | .option('open', {
|
33 | describe: 'Open a browser window',
|
34 | type: 'boolean',
|
35 | default: true,
|
36 | })
|
37 | .help();
|
38 | },
|
39 | handler: async (argv) => {
|
40 | if (!executor) {
|
41 | // eslint-disable-next-line global-require
|
42 | const HackCommand = require('./hack.cmd'); // lazy load the handler to speed up execution time
|
43 | executor = new HackCommand(getOrCreateLogger(argv));
|
44 | executor.withHackathon(argv.hackathon);
|
45 | executor.withOpen(argv.open);
|
46 | }
|
47 |
|
48 | await executor
|
49 | .run();
|
50 | },
|
51 | };
|
52 | };
|