-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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(cli): deno init --lib
#22499
feat(cli): deno init --lib
#22499
Conversation
Thanks for the PR! Can you please fix format errors? https://github.com/denoland/deno/actions/runs/8005137443/job/21863912560?pr=22499#step:26:44 |
@littledivy fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
deno init --lib
"version": "1.0.0", | ||
"exports": {}, | ||
"tasks": { | ||
"dev": "deno run --watch main.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Why does a library default to having a main.ts
? That sounds more like an application thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, probably better to do lib.ts
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe even better, mod.ts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this to mod.ts
, which is the default entrypoint name for libraries in Deno. I also changed the subcommand to deno test
, rather than deno run
, as it's a for a library, rather than a script. Happy to change, if there are better suggestions.
let project_name = dir | ||
.file_name() | ||
.unwrap_or_else(|| dir.as_os_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be problematic - I don't think all directories are valid JSR specifiers, but maybe fine for the first pass and could be improved in the future.
"version": "1.0.0", | ||
"exports": {}, | ||
"tasks": { | ||
"dev": "deno run --watch main.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, probably better to do lib.ts
instead
cli/tools/init/mod.rs
Outdated
r#"import { assertEquals } from "jsr:@std/assert"; | ||
import { add } from "./main.ts"; | ||
|
||
Deno.test(function addTest() { | ||
assertEquals(add(2, 3), 5); | ||
}); | ||
"#, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now these don't get auto-formatted 😛
nice |
#22287