Skip to content

Commit

Permalink
fix: 🐛 execute command with history record
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronConlon committed May 21, 2024
1 parent 9f99c87 commit f6f777b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions src/action/executeCommand.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -24,14 +25,27 @@ export const executeCommand = async (
});
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(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(_);
Expand Down
8 changes: 5 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -24,8 +24,6 @@ export const dynamicSelect = async (rawOptions: string[]): Promise<string> => {

let selectedIndex = 0;
const printOptions = () => {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
if ((global as any).__pause__) return;
clearScreen();
console.log(
`\ninput or pick an option with ${green("↑")} and ${green(
Expand All @@ -45,6 +43,10 @@ export const dynamicSelect = async (rawOptions: string[]): Promise<string> => {
});
if (inputString === "") {
console.log(green("\nType...\n"));
} else {
console.log(
`\n${bold().underline().blue("Input")} ${green(inputString)}\n`,
);
}
};
printOptions();
Expand Down

0 comments on commit f6f777b

Please sign in to comment.