UNPKG

1.08 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3/* eslint-disable quotes */
4
5'use strict';
6
7const program = require('commander');
8
9const getVisitor = require('../lib/visitor').getVisitor;
10
11const notifier = require('../lib/update-notifier');
12
13program
14 .name('fun validate')
15 .description('Validate a fun template.')
16 .option('-t, --template [template]', 'The path of fun template file.', 'template.[yaml|yml]')
17 .parse(process.argv);
18
19if (program.args.length) {
20 console.error();
21 console.error(" error: unexpected argument '%s'", program.args[0]);
22 program.help();
23}
24
25notifier.notify();
26
27getVisitor().then(visitor => {
28 visitor.pageview('/fun/validate').send();
29
30 require('../lib/commands/validate')(program.template)
31 .then(() => {
32 visitor.event({
33 ec: 'validate',
34 ea: 'validate',
35 el: 'success',
36 dp: '/fun/validate'
37 }).send();
38 })
39 .catch(error => {
40 visitor.event({
41 ec: 'validate',
42 ea: 'validate',
43 el: 'error',
44 dp: '/fun/validate'
45 }).send();
46
47 require('../lib/exception-handler')(error);
48 });
49});