Skip to content

Commit efe4004

Browse files
authored
chore: rename cli (#3)
1 parent 12ce7e1 commit efe4004

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To use the Request Network Injector CLI, follow these steps:
3232
2. Run the following command:
3333

3434
```shell
35-
npx request-cli
35+
npx request-injector
3636
```
3737

3838
3. Follow the prompts to select your desired functions and configurations

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "request-cli",
2+
"name": "request-injector",
33
"version": "0.1.0",
44
"description": "CLI tool for injecting Request Network functionality",
55
"bin": {
6-
"request-cli": "./dist/index.js"
6+
"request-injector": "./dist/index.js"
77
},
88
"scripts": {
99
"build": "tsc",

src/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ async function detectPackageManager(): Promise<string> {
113113
if (checkLockFile("yarn.lock")) return "yarn";
114114
if (checkLockFile("package-lock.json")) return "npm";
115115

116-
return await p.select({
116+
return (await p.select({
117117
message: "We couldn't detect your package manager. Please choose one:",
118118
options: [
119119
{ value: "npm", label: "npm" },
120120
{ value: "yarn", label: "Yarn" },
121121
{ value: "pnpm", label: "pnpm" },
122122
{ value: "bun", label: "Bun" },
123123
],
124-
});
124+
})) as string;
125125
}
126+
type PackageManager = "bun" | "pnpm" | "yarn" | "npm";
126127

127128
async function installPackages(packageManager: string, packages: Set<string>) {
128129
const installCommands = {
@@ -132,7 +133,7 @@ async function installPackages(packageManager: string, packages: Set<string>) {
132133
npm: "npm install",
133134
};
134135

135-
const installCommand = installCommands[packageManager];
136+
const installCommand = installCommands[packageManager as PackageManager];
136137

137138
const spinner = p.spinner();
138139
spinner.start(`Installing packages using ${packageManager}`);
@@ -149,7 +150,9 @@ async function installPackages(packageManager: string, packages: Set<string>) {
149150
});
150151
spinner.stop(`Packages installed successfully using ${packageManager}`);
151152
} catch (error) {
152-
spinner.stop(`Failed to install packages: ${error.message}`);
153+
if (error instanceof Error) {
154+
spinner.stop(`Failed to install packages: ${error.message}`);
155+
}
153156
throw error;
154157
}
155158
}

0 commit comments

Comments
 (0)