Skip to content

Commit 9fdb553

Browse files
committed
style: format with prettier v3
1 parent 082f95b commit 9fdb553

File tree

11 files changed

+31
-37
lines changed

11 files changed

+31
-37
lines changed

.eslintrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"extends": [
3-
"eslint-config-unjs"
4-
],
2+
"extends": ["eslint-config-unjs"],
53
"rules": {
64
"unicorn/prefer-module": 0
75
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ You can define additional [custom registry](#custom-registry) providers using `r
184184
import { registryProvider } from "giget";
185185

186186
const themes = registryProvider(
187-
"https://raw.githubusercontent.com/unjs/giget/main/templates"
187+
"https://raw.githubusercontent.com/unjs/giget/main/templates",
188188
);
189189

190190
const { source, dir } = await downloadRepo("themes:test", {

renovate.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"extends": [
3-
"github>unjs/renovate-config"
4-
]
2+
"extends": ["github>unjs/renovate-config"]
53
}

src/_utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import type { GitInfo } from "./types";
1313
export async function download(
1414
url: string,
1515
filePath: string,
16-
options: { headers?: Record<string, string> } = {}
16+
options: { headers?: Record<string, string> } = {},
1717
) {
1818
const infoPath = filePath + ".json";
1919
const info: { etag?: string } = JSON.parse(
20-
await readFile(infoPath, "utf8").catch(() => "{}")
20+
await readFile(infoPath, "utf8").catch(() => "{}"),
2121
);
2222
// eslint-disable-next-line unicorn/no-useless-undefined
2323
const headResponse = await sendFetch(url, {
@@ -34,7 +34,7 @@ export async function download(
3434
const response = await sendFetch(url, { headers: options.headers });
3535
if (response.status >= 400) {
3636
throw new Error(
37-
`Failed to download ${url}: ${response.status} ${response.statusText}`
37+
`Failed to download ${url}: ${response.status} ${response.statusText}`,
3838
);
3939
}
4040

@@ -70,7 +70,7 @@ interface InternalFetchOptions extends Exclude<RequestInit, "headers"> {
7070

7171
export async function sendFetch(
7272
url: string,
73-
options: InternalFetchOptions = {}
73+
options: InternalFetchOptions = {},
7474
) {
7575
if (!options.agent) {
7676
const proxyEnv =
@@ -123,7 +123,7 @@ export function startShell(cwd: string) {
123123
cwd = resolve(cwd);
124124
const shell = currentShell();
125125
console.info(
126-
`(experimental) Opening shell in ${relative(process.cwd(), cwd)}...`
126+
`(experimental) Opening shell in ${relative(process.cwd(), cwd)}...`,
127127
);
128128
spawnSync(shell, [], {
129129
cwd,

src/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function main() {
2525

2626
if (!input || arguments_.help || arguments_.h) {
2727
console.error(
28-
"Usage: npx giget@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry] [--no-registry] [--verbose] [--cwd] [--auth]"
28+
"Usage: npx giget@latest <input> [<dir>] [--force] [--force-clean] [--offline] [--prefer-offline] [--shell] [--registry] [--no-registry] [--verbose] [--cwd] [--auth]",
2929
);
3030
process.exit(1);
3131
}
@@ -46,8 +46,8 @@ async function main() {
4646

4747
console.log(
4848
`✨ Successfully cloned ${cyan(r.name || r.url)} to ${cyan(
49-
relative(process.cwd(), r.dir)
50-
)}\n`
49+
relative(process.cwd(), r.dir),
50+
)}\n`,
5151
);
5252

5353
if (arguments_.shell) {

src/giget.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ export type DownloadTemplateResult = Omit<TemplateInfo, "dir" | "source"> & {
3030

3131
export async function downloadTemplate(
3232
input: string,
33-
options: DownloadTemplateOptions = {}
33+
options: DownloadTemplateOptions = {},
3434
): Promise<DownloadTemplateResult> {
3535
options = defu(
3636
{
3737
registry: process.env.GIGET_REGISTRY,
3838
auth: process.env.GIGET_AUTH,
3939
},
40-
options
40+
options,
4141
);
4242

4343
const registry =
44-
options.registry !== false
45-
? registryProvider(options.registry, { auth: options.auth })
46-
: undefined;
44+
options.registry === false
45+
? undefined
46+
: registryProvider(options.registry, { auth: options.auth });
4747
let providerName: string =
4848
options.provider || (registryProvider ? "registry" : "github");
4949
let source: string = input;
@@ -62,15 +62,15 @@ export async function downloadTemplate(
6262
.then(() => provider(source, { auth: options.auth }))
6363
.catch((error) => {
6464
throw new Error(
65-
`Failed to download template from ${providerName}: ${error.message}`
65+
`Failed to download template from ${providerName}: ${error.message}`,
6666
);
6767
});
6868

6969
// Sanitize name and defaultDir
7070
template.name = (template.name || "template").replace(/[^\da-z-]/gi, "-");
7171
template.defaultDir = (template.defaultDir || template.name).replace(
7272
/[^\da-z-]/gi,
73-
"-"
73+
"-",
7474
);
7575

7676
const cwd = resolve(options.cwd || ".");
@@ -90,11 +90,11 @@ export async function downloadTemplate(
9090
const temporaryDirectory = resolve(
9191
cacheDirectory(),
9292
options.provider,
93-
template.name
93+
template.name,
9494
);
9595
const tarPath = resolve(
9696
temporaryDirectory,
97-
(template.version || template.name) + ".tar.gz"
97+
(template.version || template.name) + ".tar.gz",
9898
);
9999

100100
if (options.preferOffline && existsSync(tarPath)) {
@@ -121,7 +121,7 @@ export async function downloadTemplate(
121121

122122
if (!existsSync(tarPath)) {
123123
throw new Error(
124-
`Tarball not found: ${tarPath} (offline: ${options.offline})`
124+
`Tarball not found: ${tarPath} (offline: ${options.offline})`,
125125
);
126126
}
127127

src/registry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const DEFAULT_REGISTRY =
77

88
export const registryProvider = (
99
registryEndpoint: string = DEFAULT_REGISTRY,
10-
options?: { auth?: string }
10+
options?: { auth?: string },
1111
) => {
1212
options = options || {};
1313
return <TemplateProvider>(async (input) => {
@@ -21,19 +21,19 @@ export const registryProvider = (
2121
});
2222
if (result.status >= 400) {
2323
throw new Error(
24-
`Failed to download ${input} template info from ${registryURL}: ${result.status} ${result.statusText}`
24+
`Failed to download ${input} template info from ${registryURL}: ${result.status} ${result.statusText}`,
2525
);
2626
}
2727
const info = (await result.json()) as TemplateInfo;
2828
if (!info.tar || !info.name) {
2929
throw new Error(
30-
`Invalid template info from ${registryURL}. name or tar fields are missing!`
30+
`Invalid template info from ${registryURL}. name or tar fields are missing!`,
3131
);
3232
}
3333
debug(
3434
`Fetched ${input} template info from ${registryURL} in ${
3535
Date.now() - start
36-
}ms`
36+
}ms`,
3737
);
3838
return info;
3939
});

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export interface TemplateInfo {
2323

2424
export type TemplateProvider = (
2525
input: string,
26-
options: { auth?: string }
26+
options: { auth?: string },
2727
) => TemplateInfo | Promise<TemplateInfo> | null;

test/getgit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("downloadTemplate", () => {
2323
await mkdir(destinationDirectory).catch(() => {});
2424
await writeFile(resolve(destinationDirectory, "test.txt"), "test");
2525
await expect(
26-
downloadTemplate("gh:unjs/template", { dir: destinationDirectory })
26+
downloadTemplate("gh:unjs/template", { dir: destinationDirectory }),
2727
).rejects.toThrow("already exists");
2828
});
2929
});

tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
"moduleResolution": "Node",
66
"esModuleInterop": true
77
},
8-
"include": [
9-
"src"
10-
]
8+
"include": ["src"]
119
}

0 commit comments

Comments
 (0)