Skip to content

Commit d4d1063

Browse files
hannesrudolphdaniel-lxs
authored andcommitted
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 9e1430b commit d4d1063

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
@@ -698,6 +698,14 @@ export class CustomModesManager {
698698
return { success: false, error: "Invalid import format: no custom modes found" }
699699
}
700700

701+
// Check workspace availability early if importing at project level
702+
if (source === "project") {
703+
const workspacePath = getWorkspacePath()
704+
if (!workspacePath) {
705+
return { success: false, error: "No workspace found" }
706+
}
707+
}
708+
701709
// Process each mode in the import
702710
for (const importMode of importData.customModes) {
703711
const { rulesFiles, ...modeConfig } = importMode
@@ -711,9 +719,6 @@ export class CustomModesManager {
711719
// Only import rules files for project-level imports
712720
if (source === "project" && rulesFiles && Array.isArray(rulesFiles)) {
713721
const workspacePath = getWorkspacePath()
714-
if (!workspacePath) {
715-
return { success: false, error: "No workspace found" }
716-
}
717722

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

0 commit comments

Comments
 (0)