Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bc5302

Browse files
adding --lib flag example to init docs (denoland#1062)
1 parent 96c46b7 commit 2bc5302

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

runtime/reference/cli/init.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ addTest ... ok (6ms)
3131
ok | 1 passed | 0 failed (29ms)
3232
```
3333

34-
This subcommand will create two files (`main.ts` and `main_test.ts`). These
35-
files provide a basic example of how to write a Deno program and how to write
36-
tests for it. The `main.ts` file exports a `add` function that adds two numbers
37-
together and the `main_test.ts` file contains a test for this function.
34+
The `init` subcommand will create two files (`main.ts` and `main_test.ts`).
35+
These files provide a basic example of how to write a Deno program and how to
36+
write tests for it. The `main.ts` file exports a `add` function that adds two
37+
numbers together and the `main_test.ts` file contains a test for this function.
3838

3939
You can also specify an argument to `deno init` to initialize a project in a
4040
specific directory:
@@ -141,3 +141,30 @@ Task dev deno serve --watch -R main.ts
141141
Watcher Process started.
142142
deno serve: Listening on http://0.0.0.0:8000/
143143
```
144+
145+
## Generate a library project
146+
147+
You can append a `--lib` flag to add extra parameters to your `deno.json`, such
148+
as "name", "version" and an "exports" fields.
149+
150+
```sh
151+
$ deno init my_deno_project --lib
152+
✅ Project initialized
153+
```
154+
155+
The resulting `deno.json will be as follows:
156+
157+
```jsonc
158+
{
159+
"name": "my_deno_project",
160+
"version": "0.1.0",
161+
"exports": "./mod.ts",
162+
"tasks": {
163+
"dev": "deno test --watch mod.ts"
164+
},
165+
"license": "MIT",
166+
"imports": {
167+
"@std/assert": "jsr:@std/assert@1"
168+
}
169+
}
170+
```

0 commit comments

Comments
 (0)