mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
refactor(init): simplify template (#20325)
- Don't include benchmark file - most people won't need this. - Use deno.json instead of deno.jsonc, because it's a more common file format.
This commit is contained in:
parent
64045ebc7a
commit
f76bfbbe33
4 changed files with 4 additions and 50 deletions
|
@ -19,9 +19,8 @@ fn init_subcommand_without_dir() {
|
|||
assert_contains!(stderr, "deno run main.ts");
|
||||
assert_contains!(stderr, "deno task dev");
|
||||
assert_contains!(stderr, "deno test");
|
||||
assert_contains!(stderr, "deno bench");
|
||||
|
||||
assert!(cwd.join("deno.jsonc").exists());
|
||||
assert!(cwd.join("deno.json").exists());
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
|
@ -43,15 +42,6 @@ fn init_subcommand_without_dir() {
|
|||
output.assert_exit_code(0);
|
||||
assert_contains!(output.stdout(), "1 passed");
|
||||
output.skip_output_check();
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
.env("NO_COLOR", "1")
|
||||
.args("bench")
|
||||
.run();
|
||||
|
||||
output.assert_exit_code(0);
|
||||
output.skip_output_check();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -73,9 +63,8 @@ fn init_subcommand_with_dir_arg() {
|
|||
assert_contains!(stderr, "deno run main.ts");
|
||||
assert_contains!(stderr, "deno task dev");
|
||||
assert_contains!(stderr, "deno test");
|
||||
assert_contains!(stderr, "deno bench");
|
||||
|
||||
assert!(cwd.join("my_dir/deno.jsonc").exists());
|
||||
assert!(cwd.join("my_dir/deno.json").exists());
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
|
@ -99,16 +88,6 @@ fn init_subcommand_with_dir_arg() {
|
|||
output.assert_exit_code(0);
|
||||
assert_contains!(output.stdout(), "1 passed");
|
||||
output.skip_output_check();
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
.env("NO_COLOR", "1")
|
||||
.args("bench my_dir/main_bench.ts")
|
||||
.split_output()
|
||||
.run();
|
||||
|
||||
output.assert_exit_code(0);
|
||||
output.skip_output_check();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -125,7 +104,7 @@ fn init_subcommand_with_quiet_arg() {
|
|||
output.assert_exit_code(0);
|
||||
|
||||
assert_eq!(output.stdout(), "");
|
||||
assert!(cwd.join("deno.jsonc").exists());
|
||||
assert!(cwd.join("deno.json").exists());
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
|
@ -148,14 +127,4 @@ fn init_subcommand_with_quiet_arg() {
|
|||
output.assert_exit_code(0);
|
||||
assert_contains!(output.stdout(), "1 passed");
|
||||
output.skip_output_check();
|
||||
|
||||
let output = context
|
||||
.new_command()
|
||||
.env("NO_COLOR", "1")
|
||||
.args("bench")
|
||||
.split_output()
|
||||
.run();
|
||||
|
||||
output.assert_exit_code(0);
|
||||
output.skip_output_check();
|
||||
}
|
||||
|
|
|
@ -40,10 +40,7 @@ pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
|
|||
let main_test_ts = include_str!("./templates/main_test.ts")
|
||||
.replace("{CURRENT_STD_URL}", deno_std::CURRENT_STD_URL_STR);
|
||||
create_file(&dir, "main_test.ts", &main_test_ts)?;
|
||||
let main_bench_ts = include_str!("./templates/main_bench.ts");
|
||||
create_file(&dir, "main_bench.ts", main_bench_ts)?;
|
||||
|
||||
create_file(&dir, "deno.jsonc", include_str!("./templates/deno.jsonc"))?;
|
||||
create_file(&dir, "deno.json", include_str!("./templates/deno.json"))?;
|
||||
|
||||
info!("✅ {}", colors::green("Project initialized"));
|
||||
info!("");
|
||||
|
@ -64,8 +61,5 @@ pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
|
|||
info!("");
|
||||
info!(" {}", colors::gray("# Run the tests"));
|
||||
info!(" deno test");
|
||||
info!("");
|
||||
info!(" {}", colors::gray("# Run the benchmarks"));
|
||||
info!(" deno bench");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
import { add } from "./main.ts";
|
||||
|
||||
Deno.bench(function addSmall() {
|
||||
add(1, 2);
|
||||
});
|
||||
|
||||
Deno.bench(function addBig() {
|
||||
add(2 ** 32, 2 ** 32);
|
||||
});
|
Loading…
Reference in a new issue