UNPKG

poku

Version:

🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.

41 lines (39 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.scriptRunner = exports.runner = void 0; const node_path_1 = require("path"); const poku_js_1 = require("../configs/poku.js"); const os_js_1 = require("./os.js"); const runner = (filename) => { const { configs, runtime } = poku_js_1.GLOBAL; if (runtime === 'bun') return ['bun']; if (runtime === 'deno') { const denoAllow = configs.deno?.allow ? configs.deno.allow .map((allow) => (allow ? `--allow-${allow}` : '')) .filter((allow) => allow) : ['--allow-read', '--allow-env', '--allow-run', '--allow-net']; const denoDeny = configs.deno?.deny ? configs.deno.deny .map((deny) => (deny ? `--deny-${deny}` : '')) .filter((deny) => deny) : []; return ['deno', 'run', ...denoAllow, ...denoDeny]; } return ['.ts', '.mts', '.cts'].includes((0, node_path_1.extname)(filename)) ? [os_js_1.isWindows ? 'npx.cmd' : 'npx', 'tsx'] : ['node']; }; exports.runner = runner; const scriptRunner = (runner) => { const commands = { npm: [os_js_1.isWindows ? 'npm.cmd' : 'npm', 'run'], bun: ['bun', 'run'], deno: ['deno', 'task'], yarn: ['yarn'], pnpm: ['pnpm', 'run'], }; return commands?.[runner] ?? commands['npm']; }; exports.scriptRunner = scriptRunner;