1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.xmlLint = void 0;
|
4 | const path_1 = require("path");
|
5 | const child_process_1 = require("child_process");
|
6 | const errors_1 = require("./errors");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function xmlLint(xml) {
|
13 | const args = [
|
14 | '--schema',
|
15 | path_1.resolve(__dirname, '..', '..', 'schema', 'all.xsd'),
|
16 | '--noout',
|
17 | '-',
|
18 | ];
|
19 | if (typeof xml === 'string') {
|
20 | args[args.length - 1] = xml;
|
21 | }
|
22 | return new Promise((resolve, reject) => {
|
23 | child_process_1.execFile('which', ['xmllint'], (error, stdout, stderr) => {
|
24 | if (error) {
|
25 | reject([new errors_1.XMLLintUnavailable()]);
|
26 | return;
|
27 | }
|
28 | const xmllint = child_process_1.execFile('xmllint', args, (error, stdout, stderr) => {
|
29 | if (error) {
|
30 | reject([error, stderr]);
|
31 | }
|
32 | resolve();
|
33 | });
|
34 | if (xmllint.stdout) {
|
35 | xmllint.stdout.unpipe();
|
36 | if (typeof xml !== 'string' && xml && xmllint.stdin) {
|
37 | xml.pipe(xmllint.stdin);
|
38 | }
|
39 | }
|
40 | });
|
41 | });
|
42 | }
|
43 | exports.xmlLint = xmlLint;
|