Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow disabling remote extend with giget: false #181

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export default {
};
```

You can pass more options to `giget: {}` in layer config.
You can pass more options to `giget: {}` in layer config or disable it by setting it to `false`.

Refer to [unjs/giget](https://giget.unjs.io) for more information.

Expand Down
5 changes: 4 additions & 1 deletion src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ async function resolveConfig<
const _merger = options.merger || defu;

// Download giget URIs and resolve to local path
if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
if (
options.giget !== false &&
GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))
) {
const { downloadTemplate } = await import("giget");

const cloneName =
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export interface LoadConfigOptions<
jiti?: Jiti;
jitiOptions?: JitiOptions;

giget?: DownloadTemplateOptions;
giget?: false | DownloadTemplateOptions;

merger?: (...sources: Array<T | null | undefined>) => T;

Expand Down
12 changes: 12 additions & 0 deletions test/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ describe("loader", () => {
extends: ["github:unjs/c12/test/fixture"],
},
});
const { config: nonExtendingConfig } = await loadConfig({
name: "test",
cwd: r("./fixture/new_dir"),
giget: false,
overrides: {
extends: ["github:unjs/c12/test/fixture"],
},
});

expect(transformPaths(config!)).toMatchInlineSnapshot(`
{
Expand All @@ -258,6 +266,10 @@ describe("loader", () => {
"theme": "./theme",
}
`);

expect(transformPaths(nonExtendingConfig!)).toMatchInlineSnapshot(`
{}
`);
});

it("omit$Keys", async () => {
Expand Down