radashi-helper
Version:
Help with managing your own Radashi
49 lines (38 loc) • 2.01 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
var _chunk27XA2ZBLcjs = require('./chunk-27XA2ZBL.cjs');
var _chunkZP624W2Acjs = require('./chunk-ZP624W2A.cjs');
var _chunkST3J6QTNcjs = require('./chunk-ST3J6QTN.cjs');
require('./chunk-5R2KEZLQ.cjs');
// src/lint.ts
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
var _fs = require('fs');
var _path = require('path');
async function lint(files, options) {
const env = _nullishCoalesce(options.env, () => ( _chunkZP624W2Acjs.getEnv.call(void 0, options.dir)));
const binFiles = _fastglob2.default.sync("*", {
cwd: _path.join.call(void 0, env.root, "node_modules/.bin")
});
for (const binFile of binFiles) {
if (binFile === "biome" && _fs.existsSync.call(void 0, _path.join.call(void 0, env.root, "biome.json"))) {
const biomeGlobs = ["./src", "./tests", "./benchmarks"].flatMap(
(rootGlob) => [rootGlob, rootGlob.replace("./", "./overrides/")]
);
await _chunkST3J6QTNcjs.exec.call(void 0, "pnpm", ["biome", "check", ...biomeGlobs], {
cwd: env.root,
stdio: _chunk27XA2ZBLcjs.stdio
}).catch((error) => {
_chunkST3J6QTNcjs.log.error(error.message);
throw new (0, _chunkST3J6QTNcjs.RadashiError)("Biome failed to lint.");
});
} else if (binFile === "eslint" && (await _fastglob2.default.call(void 0, "eslint.config.*", { cwd: env.root })).length > 0) {
await _chunkST3J6QTNcjs.exec.call(void 0, "pnpm", ["eslint", ...files], {
cwd: env.root,
stdio: _chunk27XA2ZBLcjs.stdio
}).catch((error) => {
_chunkST3J6QTNcjs.log.error(error.message);
throw new (0, _chunkST3J6QTNcjs.RadashiError)("ESLint failed to lint.");
});
}
}
}
exports.lint = lint;