Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-peas-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'harmonix': patch
---

Prevent commands root dir from being categorized
2 changes: 1 addition & 1 deletion packages/harmonix/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const handleChanges = debounce(async (harmonix: Harmonix, events: Event[]) => {
for (const event of events) {
const path = resolve(event.path)
harmonix.logger.info(
`\u001B[38;2;75;67;238mhmr update\u001B[0m ${colors.dim(relative(harmonix.options.srcDir, path))}`
`\u001B[38;2;75;67;238mhmr ${event.type}\u001B[0m ${colors.dim(relative(harmonix.options.srcDir, path))}`
)

if (event.type === 'delete') {
Expand Down
20 changes: 17 additions & 3 deletions packages/harmonix/src/runtime/internal/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ export const loadModule = async <T extends AnyModule>(
module.type === ModuleType.Command &&
harmonixOptions.categorization.inferFromPath
) {
const category = filename(dirname(path))!
const inferred = inferCategoryFromPath(filePath, harmonixOptions)

module.category ??=
harmonixOptions.categorization.categories[category] ?? category
module.category ??= inferred
}

if (module.type === ModuleType.Event) {
Expand Down Expand Up @@ -98,3 +97,18 @@ export const disposeModule = async (harmonix: Harmonix, path: string) => {
}
}
}

const inferCategoryFromPath = (
filePath: string,
harmonixOptions: HarmonixOptions
) => {
const parentDir = dirname(filePath)

if (parentDir === harmonixOptions.dirs.commands) {
return undefined
}

const category = filename(parentDir)!

return harmonixOptions.categorization.categories[category] ?? category
}