UNPKG

@procore/core-scripts

Version:

A CLI to enhance your development experience

53 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const stylelint_1 = tslib_1.__importDefault(require("stylelint")); const core_1 = require("@oclif/core"); const path = tslib_1.__importStar(require("path")); const BaseCommand_1 = require("../../BaseCommand"); const config_1 = require("../../stylelint/config"); class LintStylelintCommand extends BaseCommand_1.BaseCommand { async run() { var _a, _b, _c, _d; // eslint-disable-next-line no-shadow const { flags, args } = this.parse(LintStylelintCommand); const files = (_a = args.files) !== null && _a !== void 0 ? _a : './src/**/*.(scss|sass|css|js|jsx|ts|tsx)'; const baseStylelintConfig = (0, config_1.createStylelintConfig)(); const stylelintConfig = (_d = (_c = (_b = this.workspace.procoreConfig).stylelintOverride) === null || _c === void 0 ? void 0 : _c.call(_b, baseStylelintConfig)) !== null && _d !== void 0 ? _d : baseStylelintConfig; this.workspace.writeFileSync('.stylelintrc.json', JSON.stringify(stylelintConfig, null, 2)); core_1.CliUx.ux.action.start('Linting'); const data = await stylelint_1.default.lint({ config: stylelintConfig, configBasedir: path.resolve(__dirname, '..', '..', '..', 'node_modules'), files, cache: true, fix: flags.fix, cacheLocation: './node_modules/.cache/stylelintcache', formatter: 'verbose', }); core_1.CliUx.ux.action.stop(); if (data.errored) { this.printErrors(data); } } printErrors(data) { this.error(data.output, { exit: 1 }); } } LintStylelintCommand.description = 'Runs the stylelint linter.'; LintStylelintCommand.args = [ { name: 'files', required: false, description: 'Path to the file or folder that the linter will run against.', }, ]; LintStylelintCommand.flags = { fix: command_1.flags.boolean({ default: false, description: 'Automatically fix problems.', }), }; exports.default = LintStylelintCommand; //# sourceMappingURL=stylelint.js.map