Skip to content

Commit 642e0fa

Browse files
refactor: remove formatName utility and update related references
1 parent 8959487 commit 642e0fa

6 files changed

Lines changed: 3 additions & 27 deletions

File tree

API/api.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const path = require("node:path");
1212
const url = require("node:url");
1313
const {v4: uuid} = require("uuid");
1414
const express = require("express");
15-
const {formatName} = require("../lib/utils.js");
1615

1716
const getActions = (content) => {
1817
const re = /notification ===? (?:"|')([A-Z_-]+?)(?:"|')|case (?:"|')([A-Z_-]+)(?:"|')/g;
@@ -534,7 +533,7 @@ module.exports = {
534533
id: `mc-${r.path}`,
535534
type: "menu",
536535
icon: "bars",
537-
text: formatName(r.module),
536+
text: r.module,
538537
items: []
539538
};
540539
for (const a of Object.keys(r.actions)) {

lib/utils.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ function capitalizeFirst (string) {
1313
return string.charAt(0).toUpperCase() + string.slice(1);
1414
}
1515

16-
/**
17-
* Formats a module name by removing MMM- prefix and converting to title case.
18-
* @param {string} string - The module name to format
19-
* @returns {string} Formatted module name with spaces and title case
20-
*/
21-
function formatName (string) {
22-
if (!string) return string;
23-
// Original logic: strip MMM-, split camelCase, convert delimiters to spaces & capitalize
24-
return string.replaceAll("MMM-", "").replaceAll(/([a-z])([A-Z])/g, "$1 $2").replaceAll(/(^|[-_])(\w)/g, ($0, $1, $2) => ($1 && " ") + $2.toUpperCase());
25-
}
26-
2716
/**
2817
* Checks if a string contains a pattern (null-safe).
2918
* @param {string} pattern - The pattern to search for
@@ -35,4 +24,4 @@ function includes (pattern, string) {
3524
return string.includes(pattern);
3625
}
3726

38-
module.exports = {capitalizeFirst, formatName, includes};
27+
module.exports = {capitalizeFirst, includes};

tests/unit/api.answerModuleApi.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ function makeContext (overrides = {}) {
1515
sendResponse: () => {},
1616
checkInitialized: () => true,
1717
translate: (s) => s,
18-
formatName: (s) => s,
1918
thisConfig: {},
2019
...overrides
2120
};

tests/unit/api.delayedFlow.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function makeContext (overrides = {}) {
1414
checkInitialized: () => true,
1515
checkDelay: apiModule.checkDelay,
1616
translate: (s) => s,
17-
formatName: (s) => s,
1817
delayedQuery: () => {},
1918
thisConfig: {},
2019
...overrides

tests/unit/api.helpers.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function makeContext (overrides = {}) {
1414
sendResponse: () => {},
1515
checkInitialized: () => true,
1616
translate: (s) => s,
17-
formatName: (s) => s,
1817
thisConfig: {},
1918
...overrides
2019
};

tests/unit/utils.test.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Unit tests for lib/utils.js using Node's built-in test runner */
22
const assert = require("node:assert/strict");
33
const {test, describe} = require("node:test");
4-
const {capitalizeFirst, formatName, includes} = require("../../lib/utils");
4+
const {capitalizeFirst, includes} = require("../../lib/utils");
55

66
describe("utils", () => {
77
describe("capitalizeFirst", () => {
@@ -13,15 +13,6 @@ describe("utils", () => {
1313
});
1414
});
1515

16-
describe("formatName", () => {
17-
test("removes MMM- prefix and splits camelCase", () => {
18-
assert.equal(formatName("MMM-Remote-Control"), "Remote Control");
19-
});
20-
test("converts hyphen/underscore to spaces and capitalizes", () => {
21-
assert.equal(formatName("my-module_name"), "My Module Name");
22-
});
23-
});
24-
2516
describe("includes", () => {
2617
test("returns true when substring is found", () => {
2718
assert.equal(includes("test", "this is a test string"), true);

0 commit comments

Comments
 (0)