diff --git a/package.json b/package.json index 10b0dca..8d9e34c 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "author": "Developer27149", "license": "MIT", "dependencies": { + "@inquirer/confirm": "^3.1.8", "@inquirer/select": "^2.3.2", "commander": "^12.0.0", "fdir": "^6.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20ced48..fd1c7ce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@inquirer/confirm': + specifier: ^3.1.8 + version: 3.1.8 '@inquirer/select': specifier: ^2.3.2 version: 2.3.2 @@ -347,6 +350,14 @@ packages: chalk: 5.3.0 dev: true + /@inquirer/confirm@3.1.8: + resolution: {integrity: sha512-f3INZ+ca4dQdn+MQiq1yP/mOIR/Oc8BLRYuDh6ciToWd6z4W8yArfzjBCMQ0BPY8PcJKwZxGIt8Z6yNT32eSTw==} + engines: {node: '>=18'} + dependencies: + '@inquirer/core': 8.2.1 + '@inquirer/type': 1.3.2 + dev: false + /@inquirer/core@8.1.0: resolution: {integrity: sha512-kfx0SU9nWgGe1f03ao/uXc85SFH1v2w3vQVH7QDGjKxdtJz+7vPitFtG++BTyJMYyYgH8MpXigutcXJeiQwVRw==} engines: {node: '>=18'} @@ -366,11 +377,35 @@ packages: wrap-ansi: 6.2.0 dev: false + /@inquirer/core@8.2.1: + resolution: {integrity: sha512-TIcuQMn2qrtyYe0j136UpHeYpk7AcR/trKeT/7YY0vRgcS9YSfJuQ2+PudPhSofLLsHNnRYAHScQCcVZrJkMqA==} + engines: {node: '>=18'} + dependencies: + '@inquirer/figures': 1.0.2 + '@inquirer/type': 1.3.2 + '@types/mute-stream': 0.0.4 + '@types/node': 20.12.12 + '@types/wrap-ansi': 3.0.0 + ansi-escapes: 4.3.2 + chalk: 4.1.2 + cli-spinners: 2.9.2 + cli-width: 4.1.0 + mute-stream: 1.0.0 + signal-exit: 4.1.0 + strip-ansi: 6.0.1 + wrap-ansi: 6.2.0 + dev: false + /@inquirer/figures@1.0.1: resolution: {integrity: sha512-mtup3wVKia3ZwULPHcbs4Mor8Voi+iIXEWD7wCNbIO6lYR62oPCTQyrddi5OMYVXHzeCSoneZwJuS8sBvlEwDw==} engines: {node: '>=18'} dev: false + /@inquirer/figures@1.0.2: + resolution: {integrity: sha512-4F1MBwVr3c/m4bAUef6LgkvBfSjzwH+OfldgHqcuacWwSUetFebM2wi58WfG9uk1rR98U6GwLed4asLJbwdV5w==} + engines: {node: '>=18'} + dev: false + /@inquirer/select@2.3.2: resolution: {integrity: sha512-VzLHVpaobBpI3o/CWSG2sCDqrjHZEYAfT1bowbR8Q72fEi0WfBO3Fnh595QqBit9kQhI1uJbVHaaovg1I7eE7Q==} engines: {node: '>=18'} @@ -387,6 +422,11 @@ packages: engines: {node: '>=18'} dev: false + /@inquirer/type@1.3.2: + resolution: {integrity: sha512-5Frickan9c89QbPkSu6I6y8p+9eR6hZkdPahGmNDsTFX8FHLPAozyzCZMKUeW8FyYwnlCKUjqIEqxY+UctARiw==} + engines: {node: '>=18'} + dev: false + /@types/conventional-commits-parser@5.0.0: resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==} dependencies: @@ -421,6 +461,12 @@ packages: dependencies: undici-types: 5.26.5 + /@types/node@20.12.12: + resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + dependencies: + undici-types: 5.26.5 + dev: false + /@types/picomatch@2.3.3: resolution: {integrity: sha512-Yll76ZHikRFCyz/pffKGjrCwe/le2CDwOP5F210KQo27kpRE46U2rDnzikNlVn6/ezH3Mhn46bJMTfeVTtcYMg==} dev: true diff --git a/src/action/executeCommand.ts b/src/action/executeCommand.ts index 3efad70..9f2e286 100644 --- a/src/action/executeCommand.ts +++ b/src/action/executeCommand.ts @@ -1,5 +1,6 @@ import { execSync } from "node:child_process"; import { join } from "node:path"; +import confirm from "@inquirer/confirm"; import { bold } from "kleur"; import { clearScreen } from "../utils"; import { getCommand } from "./getCommand"; @@ -24,14 +25,27 @@ export const executeCommand = async ( }); // biome-ignore lint/suspicious/noExplicitAny: (global as any).__pause__ = true; - console.log( - bold() - .underline() - .green( - "\nKeep going?Type new command or press ESC to re-pick directory.\n", - ), - ); - executeCommand(dir, dirs, windowsPowershell, rePickDirs); + console.log("\n\n\n"); + const answer = await confirm({ + message: "Keep going?", + }).catch(() => { + process.exit(0); + }); + console.log("\n"); + + if (answer) { + executeCommand(dir, dirs, windowsPowershell, rePickDirs); + } else { + rePickDirs(); + } + // console.log( + // bold() + // .underline() + // .green( + // "\nKeep going?Type new command or press ESC to re-pick directory.\n", + // ), + // ); + // executeCommand(dir, dirs, windowsPowershell, rePickDirs); } catch (_) { clearScreen(); console.log(_); diff --git a/src/utils.ts b/src/utils.ts index 554f486..8ef452f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ import readline from "node:readline"; -import { green } from "kleur"; +import { bold, green } from "kleur"; export const clearScreen = () => { process.stdout.write("\x1B[2J\x1B[0f"); @@ -24,8 +24,6 @@ export const dynamicSelect = async (rawOptions: string[]): Promise => { let selectedIndex = 0; const printOptions = () => { - // biome-ignore lint/suspicious/noExplicitAny: - if ((global as any).__pause__) return; clearScreen(); console.log( `\ninput or pick an option with ${green("↑")} and ${green( @@ -45,6 +43,10 @@ export const dynamicSelect = async (rawOptions: string[]): Promise => { }); if (inputString === "") { console.log(green("\nType...\n")); + } else { + console.log( + `\n${bold().underline().blue("Input")} ${green(inputString)}\n`, + ); } }; printOptions();