UNPKG

run-script-cli

Version:

<p align="center"> <a href="https://www.npmjs.com/package/run-script-cli" target="_blank" rel="noopener noreferrer"> <img src="https://github.com/hunghg255/run-script-cli/blob/main/assets/icon.png?raw=true" alt="logo" width='100'/></a> </p>

76 lines (70 loc) 2.34 kB
'use strict'; const process = require('node:process'); const index = require('./shared/run-script-cli.23752879.cjs'); require('node:fs'); require('node:path'); require('node:util'); require('node:child_process'); require('node:buffer'); require('child_process'); require('path'); require('fs'); require('node:url'); require('node:os'); require('node:timers/promises'); require('stream'); require('tty'); require('node:readline'); require('node:tty'); require('events'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const process__default = /*#__PURE__*/_interopDefaultCompat(process); const niCli = async (cwd = process__default.cwd(), argv = process__default.argv) => { try { const agent = await index.detectAgent(cwd); let nodeManager = agent?.name; let scriptValue = ""; if (!nodeManager) { nodeManager = await index.te({ message: index.$.bgCyan(" Choose npm manager "), options: ["npm", "pnpm", "yarn", "bun"].map((scriptItem) => ({ label: `${index.$.yellow(scriptItem)}`, value: scriptItem })) }); if (index.H(nodeManager)) { index.ne("Choose npm manager cancelled"); return process__default.exit(0); } } if (argv?.length > 2) { scriptValue = argv.slice(2).join(" "); } if (nodeManager === "bun") { const cmd = scriptValue ? `bun add ${scriptValue}` : "bun install"; index.oe(index.$.bold(index.$.green(`${cmd} `))); await index.execaCommand(`${cmd}`, { stdio: "inherit", cwd }); } if (nodeManager === "pnpm") { const cmd = scriptValue ? `pnpm add ${scriptValue}` : "pnpm install"; index.oe(index.$.bold(index.$.green(`${cmd} `))); await index.execaCommand(`${cmd}`, { stdio: "inherit", cwd }); } if (nodeManager === "npm") { index.oe(index.$.bold(index.$.green(`npm install ${scriptValue} `))); await index.execaCommand(`npm install ${scriptValue}`, { stdio: "inherit", cwd }); } if (nodeManager === "yarn") { const cmd = scriptValue ? `yarn add ${scriptValue}` : "yarn install"; index.oe(index.$.bold(index.$.green(`${cmd} `))); await index.execaCommand(`${cmd}`, { stdio: "inherit", cwd }); } } catch { } }; niCli(); exports.niCli = niCli;