summaryrefslogtreecommitdiff
path: root/cli/tools/init
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2022-12-08 06:34:28 +0100
committerGitHub <noreply@github.com>2022-12-08 06:34:28 +0100
commita6b5d05311f54d085a1e44f4a51717b4c0a4c74b (patch)
treeeb1ab43a8ec73f311fe4e4401d20df5e0d6d4a7b /cli/tools/init
parent44b2b950fd20e59fca1e6dddf522d456d2fd622f (diff)
feat(init): Generate deno.json by default (#16389)
Updates `deno init` subcommand to create a `deno.json` when initializing a new project. Slightly changes the output, to make it more readable.
Diffstat (limited to 'cli/tools/init')
-rw-r--r--cli/tools/init/mod.rs19
-rw-r--r--cli/tools/init/templates/deno.json5
2 files changed, 22 insertions, 2 deletions
diff --git a/cli/tools/init/mod.rs b/cli/tools/init/mod.rs
index 4911ca7dd..25c8dc6f4 100644
--- a/cli/tools/init/mod.rs
+++ b/cli/tools/init/mod.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use crate::args::InitFlags;
+use crate::colors;
use crate::deno_std;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
@@ -40,12 +41,26 @@ pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
.replace("{CURRENT_STD_URL}", deno_std::CURRENT_STD_URL.as_str());
create_file(&dir, "main_test.ts", &main_test_ts)?;
- info!("✅ Project initialized");
- info!("Run these commands to get started");
+ create_file(&dir, "deno.json", include_str!("./templates/deno.json"))?;
+
+ info!("✅ {}", colors::green("Project initialized"));
+ info!("");
+ info!("{}", colors::gray("Run these commands to get started"));
+ info!("");
if let Some(dir) = init_flags.dir {
info!(" cd {}", dir);
+ info!("");
}
+ info!(" {}", colors::gray("// Run the program"));
info!(" deno run main.ts");
+ info!("");
+ info!(
+ " {}",
+ colors::gray("// Run the program and watch for file changes")
+ );
+ info!(" deno task dev");
+ info!("");
+ info!(" {}", colors::gray("// Run the tests"));
info!(" deno test");
Ok(())
}
diff --git a/cli/tools/init/templates/deno.json b/cli/tools/init/templates/deno.json
new file mode 100644
index 000000000..3c5130f1d
--- /dev/null
+++ b/cli/tools/init/templates/deno.json
@@ -0,0 +1,5 @@
+{
+ "tasks": {
+ "dev": "deno run --watch main.ts"
+ }
+}