@karmaniverous/jeeves-meta 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -845,13 +845,19 @@ async function listMetas(config, watcher) {
845
845
  * @module escapeGlob
846
846
  */
847
847
  /**
848
- * Escape glob metacharacters in a string.
848
+ * Escape glob metacharacters in a string using character-class wrapping.
849
+ *
850
+ * Backslash escaping (`\(`) does not work reliably on Windows where `\` is
851
+ * the path separator. Instead, each metacharacter is wrapped in a character
852
+ * class (e.g. `(` → `[(]`) which is universally supported by glob libraries.
853
+ *
854
+ * Square brackets themselves are escaped as `[[]` and `[]]`.
849
855
  *
850
856
  * @param s - Raw path string.
851
- * @returns String with glob metacharacters backslash-escaped.
857
+ * @returns String with glob metacharacters wrapped in character classes.
852
858
  */
853
859
  function escapeGlob(s) {
854
- return s.replace(/[*?[\]{}()!]/g, '\\$&');
860
+ return s.replace(/[*?[\]{}()!]/g, (ch) => `[${ch}]`);
855
861
  }
856
862
 
857
863
  /**
@@ -1761,7 +1767,7 @@ async function mergeAndWrite(options) {
1761
1767
  */
1762
1768
  async function buildMinimalNode(metaPath, watcher) {
1763
1769
  const normalized = normalizePath(metaPath);
1764
- const ownerPath = normalizePath(dirname(metaPath));
1770
+ const ownerPath = posix.dirname(normalized);
1765
1771
  // Find child metas using watcher walk.
1766
1772
  // We include only *direct* children (nearest descendants in the ownership tree)
1767
1773
  // to match the ownership semantics used elsewhere.
@@ -1769,10 +1775,10 @@ async function buildMinimalNode(metaPath, watcher) {
1769
1775
  `${escapeGlob(ownerPath)}/**/.meta/meta.json`,
1770
1776
  ]);
1771
1777
  const candidateMetaPaths = [
1772
- ...new Set(rawMetaJsonPaths.map((p) => normalizePath(dirname(p)))),
1778
+ ...new Set(rawMetaJsonPaths.map((p) => posix.dirname(normalizePath(p)))),
1773
1779
  ].filter((p) => p !== normalized);
1774
1780
  const candidates = candidateMetaPaths
1775
- .map((mp) => ({ metaPath: mp, ownerPath: normalizePath(dirname(mp)) }))
1781
+ .map((mp) => ({ metaPath: mp, ownerPath: posix.dirname(mp) }))
1776
1782
  .sort((a, b) => a.ownerPath.length - b.ownerPath.length);
1777
1783
  const directChildren = [];
1778
1784
  for (const c of candidates) {
package/dist/index.js CHANGED
@@ -837,13 +837,19 @@ async function listMetas(config, watcher) {
837
837
  * @module escapeGlob
838
838
  */
839
839
  /**
840
- * Escape glob metacharacters in a string.
840
+ * Escape glob metacharacters in a string using character-class wrapping.
841
+ *
842
+ * Backslash escaping (`\(`) does not work reliably on Windows where `\` is
843
+ * the path separator. Instead, each metacharacter is wrapped in a character
844
+ * class (e.g. `(` → `[(]`) which is universally supported by glob libraries.
845
+ *
846
+ * Square brackets themselves are escaped as `[[]` and `[]]`.
841
847
  *
842
848
  * @param s - Raw path string.
843
- * @returns String with glob metacharacters backslash-escaped.
849
+ * @returns String with glob metacharacters wrapped in character classes.
844
850
  */
845
851
  function escapeGlob(s) {
846
- return s.replace(/[*?[\]{}()!]/g, '\\$&');
852
+ return s.replace(/[*?[\]{}()!]/g, (ch) => `[${ch}]`);
847
853
  }
848
854
 
849
855
  /**
@@ -1753,7 +1759,7 @@ async function mergeAndWrite(options) {
1753
1759
  */
1754
1760
  async function buildMinimalNode(metaPath, watcher) {
1755
1761
  const normalized = normalizePath(metaPath);
1756
- const ownerPath = normalizePath(dirname(metaPath));
1762
+ const ownerPath = posix.dirname(normalized);
1757
1763
  // Find child metas using watcher walk.
1758
1764
  // We include only *direct* children (nearest descendants in the ownership tree)
1759
1765
  // to match the ownership semantics used elsewhere.
@@ -1761,10 +1767,10 @@ async function buildMinimalNode(metaPath, watcher) {
1761
1767
  `${escapeGlob(ownerPath)}/**/.meta/meta.json`,
1762
1768
  ]);
1763
1769
  const candidateMetaPaths = [
1764
- ...new Set(rawMetaJsonPaths.map((p) => normalizePath(dirname(p)))),
1770
+ ...new Set(rawMetaJsonPaths.map((p) => posix.dirname(normalizePath(p)))),
1765
1771
  ].filter((p) => p !== normalized);
1766
1772
  const candidates = candidateMetaPaths
1767
- .map((mp) => ({ metaPath: mp, ownerPath: normalizePath(dirname(mp)) }))
1773
+ .map((mp) => ({ metaPath: mp, ownerPath: posix.dirname(mp) }))
1768
1774
  .sort((a, b) => a.ownerPath.length - b.ownerPath.length);
1769
1775
  const directChildren = [];
1770
1776
  for (const c of candidates) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-meta",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "author": "Jason Williscroft",
5
5
  "description": "Fastify HTTP service for the Jeeves Meta synthesis engine",
6
6
  "license": "BSD-3-Clause",