diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-04-24 15:45:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 19:45:49 +0000 |
commit | 2f8825a935bfdf21ca592284556cd86c1552ac8d (patch) | |
tree | 68beddeb5547861212be188f126113e6b1afc1df /cli/main.rs | |
parent | c1bd9503dd0288a3c209ca2724d2a1de9d5d122b (diff) |
feat: Add `deno serve` subcommand (#23511)
By default, `deno serve` will assign port 8000 (like `Deno.serve`).
Users may choose a different port using `--port`.
`deno serve /tmp/file.ts`
`server.ts`:
```ts
export default {
fetch(req) {
return new Response("hello world!\n");
},
};
```
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/main.rs b/cli/main.rs index a4e93ca31..142ae017c 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -33,6 +33,7 @@ use crate::util::display; use crate::util::v8::get_v8_flags_from_env; use crate::util::v8::init_v8_flags; +use deno_runtime::WorkerExecutionMode; pub use deno_runtime::UNSTABLE_GRANULAR_FLAGS; use deno_core::anyhow::Context; @@ -174,9 +175,12 @@ async fn run_subcommand(flags: Flags) -> Result<i32, AnyError> { if run_flags.is_stdin() { tools::run::run_from_stdin(flags).await } else { - tools::run::run_script(flags, run_flags).await + tools::run::run_script(WorkerExecutionMode::Run, flags, run_flags.watch).await } }), + DenoSubcommand::Serve(serve_flags) => spawn_subcommand(async move { + tools::run::run_script(WorkerExecutionMode::Serve, flags, serve_flags.watch).await + }), DenoSubcommand::Task(task_flags) => spawn_subcommand(async { tools::task::execute_script(flags, task_flags).await }), |