Skip to content

Commit 989a498

Browse files
Merge pull request #711 from denoland/main
Create a new pull request by comparing changes across two branches
2 parents ed8e18b + 1661ddd commit 989a498

File tree

11 files changed

+60
-13
lines changed

11 files changed

+60
-13
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ deno_config.workspace = true
7474
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
7575
deno_doc = { version = "=0.161.3", features = ["rust", "comrak"] }
7676
deno_error.workspace = true
77-
deno_graph = { version = "=0.86.7" }
77+
deno_graph = { version = "=0.86.8" }
7878
deno_lint = { version = "=0.68.2", features = ["docs"] }
7979
deno_lockfile.workspace = true
8080
deno_npm.workspace = true

cli/js/40_lint_selector.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ export function splitSelectors(input) {
406406
}
407407
}
408408

409-
if (last < input.length - 1) {
410-
out.push(input.slice(last).trim());
409+
const remaining = input.slice(last).trim();
410+
if (remaining.length > 0) {
411+
out.push(remaining);
411412
}
412413

413414
return out;

cli/lsp/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,8 @@ impl Settings {
853853
Some(false)
854854
} else if let Some(enable_paths) = &enable_paths {
855855
for enable_path in enable_paths {
856-
if path.starts_with(enable_path) {
856+
// Also enable if the checked path is a dir containing an enabled path.
857+
if path.starts_with(enable_path) || enable_path.starts_with(&path) {
857858
return Some(true);
858859
}
859860
}

cli/lsp/language_server.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,12 +4005,14 @@ mod tests {
40054005
temp_dir.write("root1/target/main.ts", ""); // no, because there is a Cargo.toml in the root directory
40064006

40074007
temp_dir.create_dir_all("root2/folder");
4008+
temp_dir.create_dir_all("root2/folder2/inner_folder");
40084009
temp_dir.create_dir_all("root2/sub_folder");
40094010
temp_dir.create_dir_all("root2/root2.1");
40104011
temp_dir.write("root2/file1.ts", ""); // yes, enabled
40114012
temp_dir.write("root2/file2.ts", ""); // no, not enabled
40124013
temp_dir.write("root2/folder/main.ts", ""); // yes, enabled
40134014
temp_dir.write("root2/folder/other.ts", ""); // no, disabled
4015+
temp_dir.write("root2/folder2/inner_folder/main.ts", ""); // yes, enabled (regression test for https://github.com/denoland/vscode_deno/issues/1239)
40144016
temp_dir.write("root2/sub_folder/a.js", ""); // no, not enabled
40154017
temp_dir.write("root2/sub_folder/b.ts", ""); // no, not enabled
40164018
temp_dir.write("root2/sub_folder/c.js", ""); // no, not enabled
@@ -4051,6 +4053,7 @@ mod tests {
40514053
enable_paths: Some(vec![
40524054
"file1.ts".to_string(),
40534055
"folder".to_string(),
4056+
"folder2/inner_folder".to_string(),
40544057
]),
40554058
disable_paths: vec!["folder/other.ts".to_string()],
40564059
..Default::default()
@@ -4101,6 +4104,10 @@ mod tests {
41014104
temp_dir.url().join("root1/folder/mod.ts").unwrap(),
41024105
temp_dir.url().join("root2/folder/main.ts").unwrap(),
41034106
temp_dir.url().join("root2/root2.1/main.ts").unwrap(),
4107+
temp_dir
4108+
.url()
4109+
.join("root2/folder2/inner_folder/main.ts")
4110+
.unwrap(),
41044111
])
41054112
);
41064113
}

ext/node/global.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,24 @@ const fn str_to_utf16<const N: usize>(s: &str) -> [u16; N] {
5454
// - clearTimeout (both, but different implementation)
5555
// - global (node only)
5656
// - performance (both, but different implementation)
57+
// - process (always available in Node, while the availability in Deno depends
58+
// on project creation time in Deno Deploy)
5759
// - setImmediate (node only)
5860
// - setInterval (both, but different implementation)
5961
// - setTimeout (both, but different implementation)
6062
// - window (deno only)
6163

6264
// UTF-16 encodings of the managed globals. THIS LIST MUST BE SORTED.
6365
#[rustfmt::skip]
64-
const MANAGED_GLOBALS: [&[u16]; 12] = [
66+
const MANAGED_GLOBALS: [&[u16]; 13] = [
6567
&str_to_utf16::<6>("Buffer"),
6668
&str_to_utf16::<17>("WorkerGlobalScope"),
6769
&str_to_utf16::<14>("clearImmediate"),
6870
&str_to_utf16::<13>("clearInterval"),
6971
&str_to_utf16::<12>("clearTimeout"),
7072
&str_to_utf16::<6>("global"),
7173
&str_to_utf16::<11>("performance"),
74+
&str_to_utf16::<7>("process"),
7275
&str_to_utf16::<4>("self"),
7376
&str_to_utf16::<12>("setImmediate"),
7477
&str_to_utf16::<11>("setInterval"),

ext/node/polyfills/01_require.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ Module.prototype.require = function (id) {
946946
// wrapper function we run the users code in. The only observable difference is
947947
// that in Deno `arguments.callee` is not null.
948948
Module.wrapper = [
949-
"(function (exports, require, module, __filename, __dirname, Buffer, clearImmediate, clearInterval, clearTimeout, global, setImmediate, setInterval, setTimeout, performance) { (function (exports, require, module, __filename, __dirname) {",
949+
"(function (exports, require, module, __filename, __dirname, Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout, performance) { (function (exports, require, module, __filename, __dirname) {",
950950
"\n}).call(this, exports, require, module, __filename, __dirname); })",
951951
];
952952
Module.wrap = function (script) {
@@ -1031,6 +1031,7 @@ Module.prototype._compile = function (content, filename, format) {
10311031
clearInterval,
10321032
clearTimeout,
10331033
global,
1034+
process,
10341035
setImmediate,
10351036
setInterval,
10361037
setTimeout,
@@ -1049,6 +1050,7 @@ Module.prototype._compile = function (content, filename, format) {
10491050
clearInterval,
10501051
clearTimeout,
10511052
global,
1053+
process,
10521054
setImmediate,
10531055
setInterval,
10541056
setTimeout,

ext/node/polyfills/_fs/_fs_open.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function openPromise(
153153
return new Promise((resolve, reject) => {
154154
open(path, flags, mode, (err, fd) => {
155155
if (err) reject(err);
156-
else resolve(new FileHandle(fd));
156+
else resolve(new FileHandle(fd, path));
157157
});
158158
});
159159
}

ext/node/polyfills/internal/fs/handle.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { EventEmitter } from "node:events";
77
import { Buffer } from "node:buffer";
8-
import { promises, read, write } from "node:fs";
8+
import { Mode, promises, read, write } from "node:fs";
99
export type { BigIntStats, Stats } from "ext:deno_node/_fs/_fs_stat.ts";
1010
import {
1111
BinaryOptionsArgument,
@@ -26,11 +26,15 @@ interface ReadResult {
2626
buffer: Buffer;
2727
}
2828

29+
type Path = string | Buffer | URL;
2930
export class FileHandle extends EventEmitter {
3031
#rid: number;
31-
constructor(rid: number) {
32+
#path: Path;
33+
34+
constructor(rid: number, path: Path) {
3235
super();
3336
this.#rid = rid;
37+
this.#path = path;
3438
}
3539

3640
get fd() {
@@ -144,17 +148,24 @@ export class FileHandle extends EventEmitter {
144148
stat(options?: { bigint: boolean }): Promise<Stats | BigIntStats> {
145149
return fsCall(promises.fstat, this, options);
146150
}
151+
chmod(mode: Mode): Promise<void> {
152+
assertNotClosed(this, promises.chmod.name);
153+
return promises.chmod(this.#path, mode);
154+
}
147155
}
148156

149-
function fsCall(fn, handle, ...args) {
157+
function assertNotClosed(handle: FileHandle, syscall: string) {
150158
if (handle.fd === -1) {
151159
const err = new Error("file closed");
152160
throw Object.assign(err, {
153161
code: "EBADF",
154-
syscall: fn.name,
162+
syscall,
155163
});
156164
}
165+
}
157166

167+
function fsCall(fn, handle, ...args) {
168+
assertNotClosed(handle, fn.name);
158169
return fn(handle.fd, ...args);
159170
}
160171

tests/unit/lint_selectors_test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import {
2020
import { assertThrows } from "@std/assert";
2121

2222
Deno.test("splitSelectors", () => {
23+
assertEquals(splitSelectors("*"), ["*"]);
24+
assertEquals(splitSelectors("*,*"), ["*", "*"]);
25+
assertEquals(splitSelectors("*,* "), ["*", "*"]);
2326
assertEquals(splitSelectors("foo"), ["foo"]);
2427
assertEquals(splitSelectors("foo, bar"), ["foo", "bar"]);
2528
assertEquals(splitSelectors("foo:f(bar, baz)"), ["foo:f(bar, baz)"]);

0 commit comments

Comments
 (0)