Skip to content

Commit d616753

Browse files
committed
feat(deno): add formatting
1 parent c5dccb5 commit d616753

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

templates/deno/.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deno.enable": true,
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "denoland.vscode-deno"
5+
}

templates/deno/deno.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2-
"tasks": {
3-
"format": "deno fmt",
4-
"start": "deno run --allow-read --allow-env --allow-net --allow-write main.ts --dry=true"
5-
}
2+
"tasks": {
3+
"format": "deno fmt",
4+
"start": "deno run --allow-read --allow-env --allow-net --allow-write main.ts --dry=true"
5+
},
6+
"fmt": {
7+
"singleQuote": true,
8+
"useTabs": false,
9+
"indentWidth": 4,
10+
"semiColons": true
11+
}
612
}

templates/deno/main.ts

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,36 @@
1-
import "jsr:@std/dotenv/load";
1+
import 'jsr:@std/dotenv/load';
22

3-
import { parseArgs } from "jsr:@std/cli/parse-args";
4-
import { randomIntegerBetween } from "jsr:@std/random";
3+
import { parseArgs } from 'jsr:@std/cli/parse-args';
4+
import { randomIntegerBetween } from 'jsr:@std/random';
55

66
interface User {
7-
id: string;
8-
email: string;
7+
id: string;
8+
email: string;
99
}
1010

1111
const args = parseArgs(Deno.args, {
12-
string: ["url"],
13-
boolean: ["dry"],
12+
string: ['url'],
13+
boolean: ['dry'],
1414
});
1515

16-
const user = await fetch(
17-
`https://dummyjson.com/users/${randomIntegerBetween(1, 100)}`,
18-
).then((data) => data.json()) as User;
16+
const user = (await fetch(
17+
`https://dummyjson.com/users/${randomIntegerBetween(1, 100)}`,
18+
).then((data) => data.json())) as User;
1919

2020
const data = {
21-
user: {
22-
id: user.id,
23-
email: user.email,
24-
},
25-
args: { ...args },
26-
env: { token: Deno.env.get("API_TOKEN") },
21+
user: {
22+
id: user.id,
23+
email: user.email,
24+
},
25+
args: { ...args },
26+
env: { token: Deno.env.get('API_TOKEN') },
2727
};
2828

29-
Deno.writeTextFile(
30-
"input.json",
31-
JSON.stringify(
32-
data,
33-
null,
34-
2,
35-
),
36-
);
29+
Deno.writeTextFile('input.json', JSON.stringify(data, null, 2));
3730

3831
console.log(
39-
"%cExecution completed.",
40-
"color: green",
41-
"\n",
42-
JSON.stringify({ data }, null, 2),
32+
'%cExecution completed.',
33+
'color: green',
34+
'\n',
35+
JSON.stringify({ data }, null, 2),
4336
);

0 commit comments

Comments
 (0)