From 89d08daaf53a89ef02a42657f1c53da286b87f6d Mon Sep 17 00:00:00 2001 From: Nguyen Ngoc Long <43560378+nguyenngoclongdev@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:01:07 +0000 Subject: [PATCH] fix: add cwd when import the commands --- .changeset/funny-students-marry.md | 5 +++++ src/commands/importAsync.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-students-marry.md diff --git a/.changeset/funny-students-marry.md b/.changeset/funny-students-marry.md new file mode 100644 index 0000000..d65e3a6 --- /dev/null +++ b/.changeset/funny-students-marry.md @@ -0,0 +1,5 @@ +--- +"terminal-keeper": patch +--- + +fix: add cwd when import the commands diff --git a/src/commands/importAsync.ts b/src/commands/importAsync.ts index 2946ef0..2ea1957 100644 --- a/src/commands/importAsync.ts +++ b/src/commands/importAsync.ts @@ -96,8 +96,9 @@ const chooseFilePath = async (filePaths: string[]): Promise let selectedFilePath = filePaths[0]; if (filePaths.length >= 1) { const options = filePaths.map((filePath): QuickPickItem => { + const dirname = path.dirname(filePath); const filename = path.basename(filePath); - return { label: filename, detail: filePath.replace(filename, '') }; + return { label: filename, detail: dirname }; }); const quickPickItem = await window.showQuickPick(options, { title: constants.selectFileTitle, @@ -198,9 +199,11 @@ export const importAsync = async (fileType: ImportFileType): Promise => { } // Parse to terminal item from scripts + const cwd = path.dirname(selectedFilePath); const terminalItems = Object.entries(scripts).map(([key, value]) => { const item: TerminalItem = { name: key, + cwd, commands: [value] }; return item;