1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const stylelint_1 = require("stylelint");
|
4 | class StyleLintRunner {
|
5 | constructor(config, force = false) {
|
6 | this.config = config;
|
7 | this.force = force;
|
8 | this.printResult = (data) => {
|
9 |
|
10 |
|
11 | const formattedResult = stylelint_1.formatters.string(data.results);
|
12 | console.log(formattedResult);
|
13 | if (data.errored && !this.noErrorExitCode) {
|
14 | process.exitCode = 1;
|
15 | }
|
16 | };
|
17 | this.handleUnexpectedError = (error) => {
|
18 |
|
19 | console.error(error.stack);
|
20 | if (!this.noErrorExitCode) {
|
21 | process.exitCode = 1;
|
22 | }
|
23 | };
|
24 | }
|
25 | get noErrorExitCode() {
|
26 | return this.force;
|
27 | }
|
28 | run() {
|
29 | stylelint_1.lint(this.config)
|
30 | .then(this.printResult)
|
31 | .catch(this.handleUnexpectedError);
|
32 | }
|
33 | }
|
34 | exports.StyleLintRunner = StyleLintRunner;
|