mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 20:59:10 +00:00
Merge e72f26e159
into 328d5ef2a0
This commit is contained in:
commit
2c24dd9ea1
2 changed files with 75 additions and 1 deletions
|
@ -15,6 +15,7 @@ use deno_core::futures::FutureExt;
|
||||||
use deno_core::parking_lot::Mutex;
|
use deno_core::parking_lot::Mutex;
|
||||||
use deno_lib::util::result::js_error_downcast_ref;
|
use deno_lib::util::result::js_error_downcast_ref;
|
||||||
use deno_runtime::fmt_errors::format_js_error;
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
|
use deno_signals;
|
||||||
use log::info;
|
use log::info;
|
||||||
use notify::Error as NotifyError;
|
use notify::Error as NotifyError;
|
||||||
use notify::RecommendedWatcher;
|
use notify::RecommendedWatcher;
|
||||||
|
@ -374,6 +375,9 @@ where
|
||||||
|
|
||||||
select! {
|
select! {
|
||||||
_ = receiver_future => {},
|
_ = receiver_future => {},
|
||||||
|
_ = deno_signals::ctrl_c() => {
|
||||||
|
return Ok(());
|
||||||
|
},
|
||||||
_ = restart_rx.recv() => {
|
_ = restart_rx.recv() => {
|
||||||
print_after_restart();
|
print_after_restart();
|
||||||
continue;
|
continue;
|
||||||
|
@ -407,6 +411,9 @@ where
|
||||||
// watched paths has changed.
|
// watched paths has changed.
|
||||||
select! {
|
select! {
|
||||||
_ = receiver_future => {},
|
_ = receiver_future => {},
|
||||||
|
_ = deno_signals::ctrl_c() => {
|
||||||
|
return Ok(());
|
||||||
|
},
|
||||||
_ = restart_rx.recv() => {
|
_ = restart_rx.recv() => {
|
||||||
print_after_restart();
|
print_after_restart();
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -583,7 +583,7 @@ Deno.test(
|
||||||
permissions: { run: true, read: true, write: true },
|
permissions: { run: true, read: true, write: true },
|
||||||
ignore: Deno.build.os === "windows",
|
ignore: Deno.build.os === "windows",
|
||||||
},
|
},
|
||||||
async function non_existent_cwd(): Promise<void> {
|
async function nonExistentCwd(): Promise<void> {
|
||||||
// @ts-ignore `Deno.run()` was soft-removed in Deno 2.
|
// @ts-ignore `Deno.run()` was soft-removed in Deno 2.
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
|
@ -610,3 +610,70 @@ Deno.test(
|
||||||
assertStringIncludes(stderr, "failed resolving cwd:");
|
assertStringIncludes(stderr, "failed resolving cwd:");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Deno.test(
|
||||||
|
{
|
||||||
|
permissions: { run: true, read: true, write: true },
|
||||||
|
ignore: Deno.build.os === "windows",
|
||||||
|
},
|
||||||
|
async function runWatchAndSigint(): Promise<void> {
|
||||||
|
const tempDir = await Deno.makeTempDir();
|
||||||
|
const tempFile = `${tempDir}/temp_watch_file.ts`;
|
||||||
|
await Deno.writeTextFile(tempFile, "console.log('watch test');");
|
||||||
|
|
||||||
|
// @ts-ignore `Deno.run()` was soft-removed in Deno 2.
|
||||||
|
const p = Deno.run({
|
||||||
|
cmd: ["deno", "run", "--watch", tempFile],
|
||||||
|
stdout: "piped",
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.kill(p.pid, "SIGINT");
|
||||||
|
const data = new Uint8Array(10);
|
||||||
|
const out = await p.stdout.read(data);
|
||||||
|
assertEquals(out, null);
|
||||||
|
p.stdout.close();
|
||||||
|
p.close();
|
||||||
|
|
||||||
|
await Deno.remove(tempFile);
|
||||||
|
await Deno.remove(tempDir);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Deno.test(
|
||||||
|
{
|
||||||
|
permissions: { run: true, read: true, write: true },
|
||||||
|
ignore: Deno.build.os === "windows",
|
||||||
|
},
|
||||||
|
async function runWatchWaitForSigint(): Promise<void> {
|
||||||
|
const tempDir = await Deno.makeTempDir();
|
||||||
|
const tempFile = `${tempDir}/temp_watch_file.ts`;
|
||||||
|
await Deno.writeTextFile(
|
||||||
|
tempFile,
|
||||||
|
`Deno.addSignalListener("SIGINT", () => {
|
||||||
|
console.log("SIGINT");
|
||||||
|
ac.abort();
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.serve({ signal: ac.signal }, () => new Response("Hello World"));
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// @ts-ignore `Deno.run()` was soft-removed in Deno 2.
|
||||||
|
const p = Deno.run({
|
||||||
|
cmd: ["deno", "run", "--watch", tempFile],
|
||||||
|
stdout: "piped",
|
||||||
|
stderr: "null",
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.kill(p.pid, "SIGINT");
|
||||||
|
const data = new Uint8Array(10);
|
||||||
|
const out = await p.stdout.read(data);
|
||||||
|
assertEquals(out, null);
|
||||||
|
p.stdout.close();
|
||||||
|
p.close();
|
||||||
|
|
||||||
|
await Deno.remove(tempFile);
|
||||||
|
await Deno.remove(tempDir);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue