Skip to content

Commit 2d77ff5

Browse files
committed
feat(config): set unwrapSingleRootDir to true
1 parent 9bf17c1 commit 2d77ff5

6 files changed

Lines changed: 10 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ These fields can be set in `defaults` and are inherited by every source unless o
102102
| `ignoreHidden` | Skip hidden files and directories (dotfiles). Default: `false`. |
103103
| `allowHosts` | Allowed Git hosts. Default: `["github.com", "gitlab.com", "visualstudio.com"]`. |
104104
| `toc` | Generate per-source `TOC.md`. Default: `true`. Supports `true`, `false`, or a format: `"tree"` (human readable), `"compressed"` |
105-
| `unwrapSingleRootDir` | If the materialized output is nested under a single directory, unwrap it (recursively). Default: `false`. |
105+
| `unwrapSingleRootDir` | If the materialized output is nested under a single directory, unwrap it (recursively). Default: `true`. |
106106

107107
### Source options
108108

src/cache/materialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const resolveMaterializeParams = (
175175
...params,
176176
exclude: params.exclude ?? [],
177177
ignoreHidden: params.ignoreHidden ?? false,
178-
unwrapSingleRootDir: params.unwrapSingleRootDir ?? false,
178+
unwrapSingleRootDir: params.unwrapSingleRootDir ?? true,
179179
json: params.json ?? false,
180180
progressThrottleMs: params.progressThrottleMs ?? 120,
181181
});

src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const DEFAULT_CONFIG: DocsCacheConfig = {
3939
ignoreHidden: false,
4040
allowHosts: ["github.com", "gitlab.com", "visualstudio.com"],
4141
toc: true,
42-
unwrapSingleRootDir: false,
42+
unwrapSingleRootDir: true,
4343
},
4444
sources: [],
4545
} as const;

tests/edge-cases-security.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ test("materialize handles deeply nested directories", async () => {
161161

162162
// Verify deeply nested file was materialized
163163
const { access } = await import("node:fs/promises");
164-
await access(
165-
path.join(cacheDir, "test", "a", "b", "c", "d", "e", "f", "g", "deep.md"),
166-
);
164+
await access(path.join(cacheDir, "test", "deep.md"));
167165
});
168166

169167
test("materialize handles files with special characters in names", async () => {

tests/sync-include-exclude.test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,8 @@ test("ignoreHidden excludes nested hidden directories", async () => {
247247
);
248248

249249
const docsRoot = path.join(cacheDir, "local");
250-
assert.equal(await exists(path.join(docsRoot, "docs", "guide.md")), true);
251-
assert.equal(
252-
await exists(path.join(docsRoot, "docs", ".git", "config")),
253-
false,
254-
);
250+
assert.equal(await exists(path.join(docsRoot, "guide.md")), true);
251+
assert.equal(await exists(path.join(docsRoot, ".git", "config")), false);
255252
assert.equal(
256253
await exists(path.join(docsRoot, "src", ".vscode", "settings.json")),
257254
false,
@@ -429,7 +426,7 @@ test("sync re-materializes when include rules change", async () => {
429426

430427
const docsRoot = path.join(cacheDir, "local");
431428
assert.equal(await exists(path.join(docsRoot, "README.md")), false);
432-
assert.equal(await exists(path.join(docsRoot, "docs", "guide.md")), true);
429+
assert.equal(await exists(path.join(docsRoot, "guide.md")), true);
433430

434431
const updatedConfig = {
435432
...baseConfig,
@@ -450,5 +447,5 @@ test("sync re-materializes when include rules change", async () => {
450447
await runSync(syncOptions, deps);
451448

452449
assert.equal(await exists(path.join(docsRoot, "README.md")), true);
453-
assert.equal(await exists(path.join(docsRoot, "docs", "guide.md")), false);
450+
assert.equal(await exists(path.join(docsRoot, "guide.md")), false);
454451
});

tests/sync-materialize.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,7 @@ test("sync decodes percent-encoded include patterns", async () => {
197197
},
198198
);
199199

200-
const materializedPath = path.join(
201-
cacheDir,
202-
"local",
203-
decodedDir,
204-
"README.md",
205-
);
200+
const materializedPath = path.join(cacheDir, "local", "README.md");
206201
assert.equal(await readFile(materializedPath, "utf8"), "hello");
207202
});
208203

@@ -434,7 +429,6 @@ test("sync target can unwrap single root directory", async () => {
434429
id: "local",
435430
repo: "https://example.com/repo.git",
436431
include: ["17/umbraco-forms/**"],
437-
unwrapSingleRootDir: true,
438432
},
439433
],
440434
};
@@ -529,6 +523,7 @@ test("sync re-materializes when unwrapSingleRootDir changes", async () => {
529523

530524
await writeConfigWithUnwrap(false);
531525
await run();
526+
assert.equal(await exists(path.join(cacheDir, "local", "README.md")), false);
532527
assert.equal(
533528
await exists(
534529
path.join(cacheDir, "local", "17", "umbraco-forms", "README.md"),

0 commit comments

Comments
 (0)