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>
60 lines (57 loc) • 1.62 kB
JavaScript
import process from 'node:process';
import { d as detectAgent, o as oe, $, e as execaCommand } from './shared/run-script-cli.f5e6c5d4.mjs';
import 'node:fs';
import 'node:path';
import 'node:util';
import 'node:child_process';
import 'node:buffer';
import 'child_process';
import 'path';
import 'fs';
import 'node:url';
import 'node:os';
import 'node:timers/promises';
import 'stream';
import 'tty';
import 'node:readline';
import 'node:tty';
import 'events';
const nuCli = async (cwd = process.cwd(), argv = process.argv) => {
try {
const agent = await detectAgent(cwd);
let scriptValue = "";
if (!agent?.name) {
return process.exit(0);
}
if (argv?.length > 2) {
scriptValue = argv.slice(2).join(" ");
}
if (!scriptValue) {
oe($.bold($.yellow("Please enter a package name\n")));
return;
}
if (agent.name === "bun") {
oe($.bold($.green(`bun remove ${scriptValue}
`)));
await execaCommand(`bun remove ${scriptValue}`, { stdio: "inherit", cwd });
}
if (agent.name === "pnpm") {
oe($.bold($.green(`pnpm remove ${scriptValue}
`)));
await execaCommand(`pnpm remove ${scriptValue}`, { stdio: "inherit", cwd });
}
if (agent.name === "npm") {
oe($.bold($.green(`npm uninstall ${scriptValue}
`)));
await execaCommand(`npm uninstall ${scriptValue}`, { stdio: "inherit", cwd });
}
if (agent.name === "yarn") {
oe($.bold($.green(`yarn remove ${scriptValue}
`)));
await execaCommand(`yarn remove ${scriptValue}`, { stdio: "inherit", cwd });
}
} catch {
}
};
nuCli();
export { nuCli };