radashi-helper
Version:
Help with managing your own Radashi
60 lines (50 loc) • 1.69 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _chunk27XA2ZBLcjs = require('./chunk-27XA2ZBL.cjs');
var _chunkZP624W2Acjs = require('./chunk-ZP624W2A.cjs');
var _chunkST3J6QTNcjs = require('./chunk-ST3J6QTN.cjs');
require('./chunk-5R2KEZLQ.cjs');
// src/test.ts
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
async function startTestRunner(globs, { dir, env, ...flags }) {
env ??= _chunkZP624W2Acjs.getEnv.call(void 0, dir);
let subCommand;
if (globs[0] === "run") {
subCommand = "run";
}
const args = [
"-s",
"vitest",
subCommand,
"--coverage",
...globs,
...arrifyFlags(flags)
];
if (globs.length > 0) {
const globbishRE = /(^src\b|\*)/;
const files = await _fastglob2.default.call(void 0,
globs.map((glob2) => globbishRE.test(glob2) ? glob2 : `src/**/${glob2}*`),
{
cwd: process.cwd()
}
);
for (const file of files) {
args.push("--coverage.include", file);
}
}
_chunkZP624W2Acjs.debug.call(void 0, "Running:", ["pnpm", ...args]);
await _chunkST3J6QTNcjs.exec.call(void 0, "pnpm", args, {
cwd: env.root,
stdio: _chunk27XA2ZBLcjs.stdio
});
}
function arrifyFlags(flags) {
return Object.entries(flags).flatMap(([key, value]) => {
if (key === "--") {
return [];
}
const name = value === false ? "no-" + key : key;
const flag = name.length === 1 ? `-${name}` : `--${name}`;
return value === true ? [flag] : [flag, value];
});
}
exports.startTestRunner = startTestRunner;