mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix: revert accidentally added parentPath
on DirEntry
(#24438)
Reverts the accidentally added `.parentPath` on dir entries in https://github.com/denoland/deno/pull/24257/files This should not have been added to the public api and is not documented.
This commit is contained in:
parent
f396b3d1c8
commit
d91215d418
5 changed files with 9 additions and 7 deletions
|
@ -787,7 +787,6 @@ impl FileBackedVfs {
|
||||||
.entries
|
.entries
|
||||||
.iter()
|
.iter()
|
||||||
.map(|entry| FsDirEntry {
|
.map(|entry| FsDirEntry {
|
||||||
parent_path: path.to_string_lossy().into_owned(),
|
|
||||||
name: entry.name().to_string(),
|
name: entry.name().to_string(),
|
||||||
is_file: matches!(entry, VfsEntry::File(_)),
|
is_file: matches!(entry, VfsEntry::File(_)),
|
||||||
is_directory: matches!(entry, VfsEntry::Dir(_)),
|
is_directory: matches!(entry, VfsEntry::Dir(_)),
|
||||||
|
|
|
@ -69,10 +69,10 @@ pub enum FsFileType {
|
||||||
Junction,
|
Junction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// WARNING: This is part of the public JS Deno API.
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FsDirEntry {
|
pub struct FsDirEntry {
|
||||||
pub parent_path: String,
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub is_file: bool,
|
pub is_file: bool,
|
||||||
pub is_directory: bool,
|
pub is_directory: bool,
|
||||||
|
|
|
@ -814,7 +814,6 @@ fn read_dir(path: &Path) -> FsResult<Vec<FsDirEntry>> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Some(FsDirEntry {
|
Some(FsDirEntry {
|
||||||
parent_path: path.to_string_lossy().to_string(),
|
|
||||||
name,
|
name,
|
||||||
is_file: method_or_false!(is_file),
|
is_file: method_or_false!(is_file),
|
||||||
is_directory: method_or_false!(is_dir),
|
is_directory: method_or_false!(is_dir),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
|
|
||||||
export default class Dirent {
|
export default class Dirent {
|
||||||
constructor(private entry: Deno.DirEntry) {}
|
constructor(private entry: Deno.DirEntry & { parentPath: string }) {}
|
||||||
|
|
||||||
isBlockDevice(): boolean {
|
isBlockDevice(): boolean {
|
||||||
notImplemented("Deno does not yet support identification of block devices");
|
notImplemented("Deno does not yet support identification of block devices");
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { promisify } from "ext:deno_node/internal/util.mjs";
|
import { promisify } from "ext:deno_node/internal/util.mjs";
|
||||||
|
|
||||||
function toDirent(val: Deno.DirEntry): Dirent {
|
function toDirent(val: Deno.DirEntry & { parentPath: string }): Dirent {
|
||||||
return new Dirent(val);
|
return new Dirent(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +67,15 @@ export function readdir(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
asyncIterableToCallback(Deno.readDir(path.toString()), (val, done) => {
|
path = path.toString();
|
||||||
|
asyncIterableToCallback(Deno.readDir(path), (val, done) => {
|
||||||
if (typeof path !== "string") return;
|
if (typeof path !== "string") return;
|
||||||
if (done) {
|
if (done) {
|
||||||
callback(null, result);
|
callback(null, result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (options?.withFileTypes) {
|
if (options?.withFileTypes) {
|
||||||
|
val.parentPath = path;
|
||||||
result.push(toDirent(val));
|
result.push(toDirent(val));
|
||||||
} else result.push(decode(val.name));
|
} else result.push(decode(val.name));
|
||||||
}, (e) => {
|
}, (e) => {
|
||||||
|
@ -130,8 +132,10 @@ export function readdirSync(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const file of Deno.readDirSync(path.toString())) {
|
path = path.toString();
|
||||||
|
for (const file of Deno.readDirSync(path)) {
|
||||||
if (options?.withFileTypes) {
|
if (options?.withFileTypes) {
|
||||||
|
file.parentPath = path;
|
||||||
result.push(toDirent(file));
|
result.push(toDirent(file));
|
||||||
} else result.push(decode(file.name));
|
} else result.push(decode(file.name));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue