@putkoff/abstract-utilities 1.0.27 → 1.0.28

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.
package/dist/cjs/index.js CHANGED
@@ -1552,77 +1552,72 @@ function getMimeType(pathOrExt) {
1552
1552
  }
1553
1553
  return "application/octet-stream";
1554
1554
  }
1555
- /**
1556
- * Recursively collect files under `directory` whose extension is in `categories`.
1557
- * Synchronous version.
1558
- */
1559
1555
  function getAllFileTypesSync(directory, categories, opts) {
1560
- const base = directory;
1561
- let stat;
1556
+ // 🧩 Skip entirely if fs isn't available
1557
+ if (!fs__namespace || !path__namespace)
1558
+ return [];
1562
1559
  try {
1563
- stat = fs__namespace.statSync(base);
1560
+ const stat = fs__namespace.statSync(directory);
1561
+ if (!stat.isDirectory())
1562
+ return [];
1563
+ const cats = normalizeCategories(categories, opts);
1564
+ const wanted = unionExts(cats);
1565
+ const results = [];
1566
+ function walkSync(dir) {
1567
+ const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
1568
+ for (const ent of entries) {
1569
+ const full = path__namespace.join(dir, ent.name);
1570
+ if (ent.isDirectory()) {
1571
+ walkSync(full);
1572
+ }
1573
+ else if (ent.isFile()) {
1574
+ const ext = path__namespace.extname(ent.name).toLowerCase();
1575
+ if (wanted.has(ext))
1576
+ results.push(full);
1577
+ }
1578
+ }
1579
+ }
1580
+ walkSync(directory);
1581
+ return results;
1564
1582
  }
1565
1583
  catch (_a) {
1566
1584
  return [];
1567
1585
  }
1568
- if (!stat.isDirectory())
1569
- return [];
1570
- const cats = normalizeCategories(categories, opts);
1571
- const wanted = unionExts(cats);
1572
- const results = [];
1573
- function walkSync(dir) {
1574
- const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
1575
- for (const ent of entries) {
1576
- const full = path__namespace.join(dir, ent.name);
1577
- if (ent.isDirectory()) {
1578
- walkSync(full);
1579
- }
1580
- else if (ent.isFile()) {
1581
- const ext = path__namespace.extname(ent.name).toLowerCase();
1582
- if (wanted.has(ext))
1583
- results.push(full);
1584
- }
1585
- }
1586
- }
1587
- walkSync(base);
1588
- return results;
1589
1586
  }
1590
- /**
1591
- * Recursively collect files under `directory` whose extension is in `categories`.
1592
- * Async/Promise version.
1593
- */
1594
1587
  function getAllFileTypes(directory, categories, opts) {
1595
1588
  return __awaiter(this, void 0, void 0, function* () {
1596
- let stat;
1589
+ // 🧩 Skip entirely if fsp isn't available
1590
+ if (!fsp__namespace || !path__namespace)
1591
+ return [];
1597
1592
  try {
1598
- stat = yield fsp__namespace.stat(directory);
1593
+ const stat = yield fsp__namespace.stat(directory);
1594
+ if (!stat.isDirectory())
1595
+ return [];
1596
+ const cats = normalizeCategories(categories, opts);
1597
+ const wanted = unionExts(cats);
1598
+ const results = [];
1599
+ function walkAsync(dir) {
1600
+ return __awaiter(this, void 0, void 0, function* () {
1601
+ const entries = yield fsp__namespace.readdir(dir, { withFileTypes: true });
1602
+ for (const ent of entries) {
1603
+ const full = path__namespace.join(dir, ent.name);
1604
+ if (ent.isDirectory()) {
1605
+ yield walkAsync(full);
1606
+ }
1607
+ else if (ent.isFile()) {
1608
+ const ext = path__namespace.extname(ent.name).toLowerCase();
1609
+ if (wanted.has(ext))
1610
+ results.push(full);
1611
+ }
1612
+ }
1613
+ });
1614
+ }
1615
+ yield walkAsync(directory);
1616
+ return results;
1599
1617
  }
1600
1618
  catch (_a) {
1601
1619
  return [];
1602
1620
  }
1603
- if (!stat.isDirectory())
1604
- return [];
1605
- const cats = normalizeCategories(categories, opts);
1606
- const wanted = unionExts(cats);
1607
- const results = [];
1608
- function walkAsync(dir) {
1609
- return __awaiter(this, void 0, void 0, function* () {
1610
- const entries = yield fsp__namespace.readdir(dir, { withFileTypes: true });
1611
- for (const ent of entries) {
1612
- const full = path__namespace.join(dir, ent.name);
1613
- if (ent.isDirectory()) {
1614
- yield walkAsync(full);
1615
- }
1616
- else if (ent.isFile()) {
1617
- const ext = path__namespace.extname(ent.name).toLowerCase();
1618
- if (wanted.has(ext))
1619
- results.push(full);
1620
- }
1621
- }
1622
- });
1623
- }
1624
- yield walkAsync(directory);
1625
- return results;
1626
1621
  });
1627
1622
  }
1628
1623
  /** Optional convenience re-exports that mirror your Python names */