@kenjura/ursa 0.7.0 → 0.8.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.8.0
2
+
3
+ 2023-12-31
4
+
5
+ - Fixed recursive-readdir to actually return directories, not just files
6
+
1
7
  # 0.7.0
2
8
 
3
9
  2023-08-01
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kenjura/ursa",
3
3
  "author": "Andrew London <andrew@kenjura.com>",
4
4
  "type": "module",
5
- "version": "0.7.0",
5
+ "version": "0.8.0",
6
6
  "description": "static site generator from MD/wikitext/YML",
7
7
  "main": "lib/index.js",
8
8
  "scripts": {
@@ -1,11 +1,13 @@
1
- import { resolve } from 'path';
2
- import { readdir } from 'fs/promises';
1
+ import { resolve } from "path";
2
+ import { readdir } from "fs/promises";
3
3
 
4
4
  export async function recurse(dir) {
5
5
  const dirents = await readdir(dir, { withFileTypes: true });
6
- const files = await Promise.all(dirents.map((dirent) => {
7
- const res = resolve(dir, dirent.name);
8
- return dirent.isDirectory() ? recurse(res) : res;
9
- }));
6
+ const files = await Promise.all(
7
+ dirents.map(async (dirent) => {
8
+ const res = resolve(dir, dirent.name);
9
+ return dirent.isDirectory() ? [res, ...(await recurse(res))] : res;
10
+ })
11
+ );
10
12
  return Array.prototype.concat(...files);
11
- }
13
+ }