1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | const program = require('commander');
|
8 | const getVisitor = require('../lib/visitor').getVisitor;
|
9 | const notifier = require('../lib/update-notifier');
|
10 | const { autoExit } = require('../lib/unref-timeout');
|
11 |
|
12 | program
|
13 | .name('fun build')
|
14 | .usage('[options] [[service/]function]')
|
15 | .description('Build the dependencies.')
|
16 | .option('-d, --use-docker', 'Use docker container to build functions')
|
17 | .option('-t, --template [template]', 'The path of fun template file.')
|
18 | .parse(process.argv);
|
19 |
|
20 | if (program.args.length > 1) {
|
21 | console.error();
|
22 | console.error(" error: unexpected argument '%s'", program.args[0]);
|
23 | program.help();
|
24 | }
|
25 |
|
26 | notifier.notify();
|
27 |
|
28 | getVisitor().then(visitor => {
|
29 | visitor.pageview('/fun/build').send();
|
30 |
|
31 | program.verbose = parseInt(process.env.FUN_VERBOSE) > 0;
|
32 |
|
33 | require('../lib/commands/build')(program.args[0], program)
|
34 | .then(() => {
|
35 | visitor.event({
|
36 | ec: 'build',
|
37 | ea: 'build',
|
38 | el: 'success',
|
39 | dp: '/fun/build'
|
40 | }).send();
|
41 |
|
42 | autoExit();
|
43 | })
|
44 | .catch(error => {
|
45 | visitor.event({
|
46 | ec: 'build',
|
47 | ea: 'build',
|
48 | el: 'error',
|
49 | dp: '/fun/build'
|
50 | }).send();
|
51 |
|
52 | require('../lib/exception-handler')(error);
|
53 | });
|
54 | });
|
55 |
|
56 |
|