Skip to content

Commit 074fc69

Browse files
committed
fix: check workspace availability before using path.join in importModeWithRules
- Add early workspace check when importing at project level - Prevents 'path.join' error when workspace is null - Ensures proper 'No workspace found' error message is returned
1 parent d62d372 commit 074fc69

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,14 @@ export class CustomModesManager {
611611
return { success: false, error: "Invalid import format: no custom modes found" }
612612
}
613613

614+
// Check workspace availability early if importing at project level
615+
if (source === "project") {
616+
const workspacePath = getWorkspacePath()
617+
if (!workspacePath) {
618+
return { success: false, error: "No workspace found" }
619+
}
620+
}
621+
614622
// Process each mode in the import
615623
for (const importMode of importData.customModes) {
616624
const { rulesFiles, ...modeConfig } = importMode
@@ -624,9 +632,6 @@ export class CustomModesManager {
624632
// Only import rules files for project-level imports
625633
if (source === "project" && rulesFiles && Array.isArray(rulesFiles)) {
626634
const workspacePath = getWorkspacePath()
627-
if (!workspacePath) {
628-
return { success: false, error: "No workspace found" }
629-
}
630635

631636
// First, remove the existing rules folder for this mode if it exists
632637
const rulesFolderPath = path.join(workspacePath, ".roo", `rules-${importMode.slug}`)

0 commit comments

Comments
 (0)