Skip to content

Commit 771fcce

Browse files
authored
feat: allow disabling remote extend with giget: false (#181)
1 parent 5b0c89c commit 771fcce

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export default {
304304
};
305305
```
306306

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

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

src/loader.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ async function resolveConfig<
302302
const _merger = options.merger || defu;
303303

304304
// Download giget URIs and resolve to local path
305-
if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
305+
if (
306+
options.giget !== false &&
307+
GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))
308+
) {
306309
const { downloadTemplate } = await import("giget");
307310

308311
const cloneName =

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export interface LoadConfigOptions<
131131
jiti?: Jiti;
132132
jitiOptions?: JitiOptions;
133133

134-
giget?: DownloadTemplateOptions;
134+
giget?: false | DownloadTemplateOptions;
135135

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

test/loader.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ describe("loader", () => {
233233
extends: ["github:unjs/c12/test/fixture"],
234234
},
235235
});
236+
const { config: nonExtendingConfig } = await loadConfig({
237+
name: "test",
238+
cwd: r("./fixture/new_dir"),
239+
giget: false,
240+
overrides: {
241+
extends: ["github:unjs/c12/test/fixture"],
242+
},
243+
});
236244

237245
expect(transformPaths(config!)).toMatchInlineSnapshot(`
238246
{
@@ -258,6 +266,10 @@ describe("loader", () => {
258266
"theme": "./theme",
259267
}
260268
`);
269+
270+
expect(transformPaths(nonExtendingConfig!)).toMatchInlineSnapshot(`
271+
{}
272+
`);
261273
});
262274

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

0 commit comments

Comments
 (0)