UNPKG

netkitty

Version:
26 lines (25 loc) 1.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const inquirer_1 = __importDefault(require("inquirer")); const node_fs_1 = require("node:fs"); const node_path_1 = __importDefault(require("node:path")); const node_child_process_1 = require("node:child_process"); const unitDir = node_path_1.default.resolve(__dirname, './units'); const unitModules = (0, node_fs_1.readdirSync)(unitDir).filter(unit => unit.endsWith('spec.js')).map(unit => node_path_1.default.resolve(unitDir, unit)); inquirer_1.default .prompt([ { type: 'list', name: 'unit', message: 'Select an unit to test', choices: unitModules.map(unitPath => node_path_1.default.basename(unitPath, '.spec.js')) } ]) .then(async (answers) => { const [selectedModule] = unitModules.filter(unitPath => node_path_1.default.basename(unitPath, '.spec.js') === answers.unit); (0, node_child_process_1.fork)(selectedModule); }) .catch(console.error);