UNPKG

ffbt

Version:

Build a Typescript app without pain

36 lines (35 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StyleLintRunner = void 0; const stylelint_1 = require("stylelint"); class StyleLintRunner { constructor(config, force = false) { this.config = config; this.force = force; this.printResult = (data) => { // do things with data.output, data.errored, // and data.results const formattedResult = stylelint_1.formatters.string(data.results); console.log(formattedResult); // eslint-disable-line no-console if (data.errored && !this.noErrorExitCode) { process.exitCode = 1; } }; this.handleUnexpectedError = (error) => { // do things with err e.g. console.error(error.stack); // eslint-disable-line no-console if (!this.noErrorExitCode) { process.exitCode = 1; } }; } get noErrorExitCode() { return this.force; } run() { stylelint_1.lint(this.config) .then(this.printResult) .catch(this.handleUnexpectedError); } } exports.StyleLintRunner = StyleLintRunner;