UNPKG

@rodbe/nsl

Version:

List, fuzzy search and run scripts from any type of project

50 lines (47 loc) 1.3 kB
#!/usr/bin/env node import chalk from 'chalk'; import select from '@inquirer/select'; import { i as initEvents, r as rerunCache, e as execScript } from '../index-tTGo6WbU.js'; import 'node:path'; import 'node:child_process'; import '@rodbe/fn-utils'; import '@rodbe/lru-cache-fs'; import 'node:url'; import 'node:fs'; import 'node:os'; import 'node:process'; initEvents(); const init = async () => { const cwd = process.cwd(); const rrCache = rerunCache(); const cached = rrCache.get(cwd); if (cached) { const { debug, print, rootPkgManager, answerSelected, commandToRun } = cached; const rerunOpts = { choices: [ { name: "Yes", value: true }, { name: "No", value: false } ], default: true, message: `Do you want to rerun: ${chalk.black.bold.bgGreenBright(commandToRun.root)}` }; const res = await select(rerunOpts); if (!res) { return; } if (debug || print) { console.log(chalk.black.bold.bgGreenBright("NSL params ->"), { debug, print }); } execScript({ answerSelected, cwd, debug, print, rootPkgManager }); } else { console.log(chalk.white.bold.bgMagenta(`Hey, there is no "last script" to run`)); } }; await init(); export { init };