From 75f00eecb0cf5e0002fe52da94d764fc6cb0e817 Mon Sep 17 00:00:00 2001 From: Chris Veness Date: Sat, 26 Oct 2024 23:12:40 +0100 Subject: [PATCH 1/4] fix(cli): Make --watcher CLEAR_SCREEN clear scrollback buffer as well as visible screen (#25997) The --watch option should clear the screen scrollback buffer as well as the screen itself. On Ubuntu (22.04 Jammy) the 'clear' command generates "\x1B[H\x1B[2J\x1B[3J"; that is: - \E[H - cursor home - \E[2J - clear entire screen - \E[3J - clear entire screen & scrollback buffer. By contrast, Deno defined CLEAR_SCREEN as "\x1B[2J\x1B[1;1H", which fails to clear the scrollback buffer. The "\E[H\E[2J\E[3J" sequence works on MacOS (Sonoma) (using printf); I'm not able to test on Windows. Closes https://github.com/denoland/deno/issues/26514 --- cli/util/file_watcher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index d92d880bc1..8d734af88e 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -30,7 +30,7 @@ use tokio::sync::mpsc; use tokio::sync::mpsc::UnboundedReceiver; use tokio::time::sleep; -const CLEAR_SCREEN: &str = "\x1B[2J\x1B[1;1H"; +const CLEAR_SCREEN: &str = "\x1B[H\x1B[2J\x1B[3J"; const DEBOUNCE_INTERVAL: Duration = Duration::from_millis(200); struct DebouncedReceiver { From ab3d02a08174042c6337d130b02a6fa0f85673d2 Mon Sep 17 00:00:00 2001 From: Meir Blachman Date: Sun, 27 Oct 2024 01:31:44 +0200 Subject: [PATCH 2/4] docs(readme): Add winget instructions (#25136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Meir Blachman Co-authored-by: Bartek IwaƄczuk --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 102319f4f2..19d4fa8a12 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ brew install deno choco install deno ``` +[WinGet](https://winstall.app/apps/DenoLand.Deno) (Windows): + +```powershell +winget install --id=DenoLand.Deno +``` + ### Build and install from source Complete instructions for building Deno from source can be found in the manual From 05868cc2367d6c827691d7624478157239048bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 27 Oct 2024 03:00:19 +0000 Subject: [PATCH 3/4] fix(watch): don't panic on invalid file specifiers (#26577) Removes an unwrap that falsely assumed the specifier is a valid file path. Fixes https://github.com/denoland/deno/issues/26209 --- cli/graph_util.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/graph_util.rs b/cli/graph_util.rs index e67ae7821b..2eaee228af 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -1009,7 +1009,11 @@ impl deno_graph::source::Reporter for FileWatcherReporter { ) { let mut file_paths = self.file_paths.lock(); if specifier.scheme() == "file" { - file_paths.push(specifier.to_file_path().unwrap()); + // Don't trust that the path is a valid path at this point: + // https://github.com/denoland/deno/issues/26209. + if let Ok(file_path) = specifier.to_file_path() { + file_paths.push(file_path); + } } if modules_done == modules_total { From c314b2d8577289078d6b00a0dd58f8f36ff6920a Mon Sep 17 00:00:00 2001 From: familyboat <84062528+familyboat@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:04:35 +0800 Subject: [PATCH 4/4] fix(ext/node): add path to `fs.stat` and `fs.statSync` error (#26037) --- ext/node/polyfills/_fs/_fs_stat.ts | 14 ++++++++-- tests/unit_node/fs_test.ts | 43 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/ext/node/polyfills/_fs/_fs_stat.ts b/ext/node/polyfills/_fs/_fs_stat.ts index c4ed82d577..d00c81ffb6 100644 --- a/ext/node/polyfills/_fs/_fs_stat.ts +++ b/ext/node/polyfills/_fs/_fs_stat.ts @@ -383,7 +383,10 @@ export function stat( Deno.stat(path).then( (stat) => callback(null, CFISBIS(stat, options.bigint)), - (err) => callback(denoErrorToNodeError(err, { syscall: "stat" })), + (err) => + callback( + denoErrorToNodeError(err, { syscall: "stat", path: getPathname(path) }), + ), ); } @@ -417,9 +420,16 @@ export function statSync( return; } if (err instanceof Error) { - throw denoErrorToNodeError(err, { syscall: "stat" }); + throw denoErrorToNodeError(err, { + syscall: "stat", + path: getPathname(path), + }); } else { throw err; } } } + +function getPathname(path: string | URL) { + return typeof path === "string" ? path : path.pathname; +} diff --git a/tests/unit_node/fs_test.ts b/tests/unit_node/fs_test.ts index ef8f829cda..631608d7cc 100644 --- a/tests/unit_node/fs_test.ts +++ b/tests/unit_node/fs_test.ts @@ -26,6 +26,7 @@ import { cp, FileHandle, open, + stat, writeFile, } from "node:fs/promises"; import process from "node:process"; @@ -123,6 +124,48 @@ Deno.test( }, ); +Deno.test( + "[node/fs statSync] throw error with path information", + () => { + const file = "non-exist-file"; + const fileUrl = new URL(file, import.meta.url); + + assertThrows(() => { + statSync(file); + }, "Error: ENOENT: no such file or directory, stat 'non-exist-file'"); + + assertThrows(() => { + statSync(fileUrl); + }, `Error: ENOENT: no such file or directory, stat '${fileUrl.pathname}'`); + }, +); + +Deno.test( + "[node/fs/promises stat] throw error with path information", + async () => { + const file = "non-exist-file"; + const fileUrl = new URL(file, import.meta.url); + + try { + await stat(file); + } catch (error: unknown) { + assertEquals( + `${error}`, + "Error: ENOENT: no such file or directory, stat 'non-exist-file'", + ); + } + + try { + await stat(fileUrl); + } catch (error: unknown) { + assertEquals( + `${error}`, + `Error: ENOENT: no such file or directory, stat '${fileUrl.pathname}'`, + ); + } + }, +); + Deno.test( "[node/fs/promises cp] copy file", async () => {