Skip to content

Commit

Permalink
Refactor getActiveFileFolderPath to return an object with activeFileF…
Browse files Browse the repository at this point in the history
…olderPath and update generateCodeCommand to use the new structure
  • Loading branch information
jeremytenjo committed Feb 4, 2025
1 parent ca81663 commit 0733b1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/commands/generateCodeCommand/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import logError from '../../../utils/log/logError'
import getActiveFileFolderPath from '../../../utils/folderFiles/getActiveFileFolderPath'

export default async function generateCodeCommand(
{ path: componentOutputPath } = { path: getActiveFileFolderPath() },
{ path: componentOutputPath } = {
path: getActiveFileFolderPath().activeFileFolderPath,
},
) {
try {
await generateCode({ outputPath: componentOutputPath })
Expand Down
8 changes: 6 additions & 2 deletions utils/folderFiles/getActiveFileFolderPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { sep } from 'path'
/**
* Get the folder path of the currently open and active vscode file
*/
export default function getActiveFileFolderPath(): string {
export default function getActiveFileFolderPath() {
const activeFilePath = getActiveFilePath()
// split the path into an array
const activeFileFolder: string[] = splitPath(activeFilePath)
// remove the last element
activeFileFolder.pop()

return activeFileFolder.join(sep)
const activeFileFolderPath = activeFileFolder.join(sep)

return {
activeFileFolderPath,
}
}

0 comments on commit 0733b1f

Please sign in to comment.