-
-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathvalidate.ts
34 lines (27 loc) · 940 Bytes
/
validate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Flags } from '@oclif/core';
import Command from '../base';
import { validate, validationFlags } from '../parser';
import { load } from '../models/SpecificationFile';
import { specWatcher } from '../globals';
import { watchFlag } from '../flags';
export default class Validate extends Command {
static description = 'validate asyncapi file';
static flags = {
help: Flags.help({ char: 'h' }),
watch: watchFlag(),
...validationFlags(),
};
static args = [
{ name: 'spec-file', description: 'spec path, url, or context-name', required: false },
];
async run() {
const { args, flags } = await this.parse(Validate); //NOSONAR
const filePath = args['spec-file'];
const watchMode = flags.watch;
const specFile = await load(filePath);
if (watchMode) {
specWatcher({ spec: specFile, handler: this, handlerName: 'validate' });
}
await validate(this, specFile, flags);
}
}