fix handle.kind
Release / release (push) Successful in 23s

This commit is contained in:
2026-05-01 11:03:08 -07:00
parent f361c6b931
commit 40424dde59
3 changed files with 8 additions and 1 deletions
+6 -1
View File
@@ -16,7 +16,12 @@ for (let i = 0; i < 10000; i++) {
const text = await file.text()
if (text !== textText) throw new Error("failed to read back written data")
}
for await (const [name, handle] of test_directory_handle) { }
for await (const [name, handle] of cwd_directory_handle) {
console.log(`${name} is a ${handle.kind}`)
if (handle.kind !== "directory" && handle.kind !== "file") {
throw new Error("invalid handle kind")
}
}
console.log("iterable pass")
const result = await cwd_directory_handle.getFileHandle('test/test.txt').catch(error => 'blocked path traversal')
if (typeof result === 'string') console.log(result)
+1
View File
@@ -16,6 +16,7 @@ export default class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle
declare kind: "directory";
constructor(path: string, options: FileSystemGetDirectoryOptions & { origin?: NodeFileSystemDirectoryHandle } = {}) {
super(path, options)
this.kind="directory"
try {
const stats = fs.statSync(this.path)
if (!stats.isDirectory()) throw new Error("tried to open file as directory: " + this.path)
+1
View File
@@ -17,6 +17,7 @@ export default class NodeFileSystemFileHandle extends NodeFileSystemHandle imple
declare kind: "file";
constructor(path: string, options: FileSystemGetFileOptions & { origin?: NodeFileSystemDirectoryHandle } = {}) {
super(path,options)
this.kind="file"
let flags = fs.constants.O_RDWR
if (options.create) flags |= fs.constants.O_CREAT
fs.closeSync(fs.openSync(this.path, flags))