Skip to content

Commit

Permalink
fix(NodeFsStats): is_symlink is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
nilptr committed Dec 11, 2024
1 parent bb6a352 commit a888835
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ export interface JsTap {
export interface NodeFsStats {
isFile: boolean
isDirectory: boolean
isSymlink: boolean
atimeMs: number
mtimeMs: number
ctimeMs: number
Expand Down
3 changes: 2 additions & 1 deletion crates/rspack_fs_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct ThreadsafeNodeFS {
pub struct NodeFsStats {
pub is_file: bool,
pub is_directory: bool,
pub is_symlink: bool,
pub atime_ms: u32,
pub mtime_ms: u32,
pub ctime_ms: u32,
Expand All @@ -59,7 +60,7 @@ impl From<NodeFsStats> for FileMetadata {
Self {
is_file: value.is_file,
is_directory: value.is_directory,
is_symlink: false,
is_symlink: value.is_symlink,
atime_ms: value.atime_ms as u64,
mtime_ms: value.mtime_ms as u64,
ctime_ms: value.ctime_ms as u64,
Expand Down
13 changes: 2 additions & 11 deletions packages/rspack/src/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,7 @@ class ThreadsafeOutputNodeFS implements ThreadsafeNodeFS {
const statFn = util.promisify(fs.stat.bind(fs));
return async (filePath: string) => {
const res = await statFn(filePath);
return (
res && {
isFile: res.isFile(),
isDirectory: res.isDirectory(),
atimeMs: res.atimeMs,
mtimeMs: res.atimeMs,
ctimeMs: res.atimeMs,
birthtimeMs: res.birthtimeMs,
size: res.size
}
);
return res && ThreadsafeOutputNodeFS.__to_binding_stat(res);
};
});
this.lstat = memoizeFn(() => {
Expand All @@ -117,6 +107,7 @@ class ThreadsafeOutputNodeFS implements ThreadsafeNodeFS {
return {
isFile: stat.isFile(),
isDirectory: stat.isDirectory(),
isSymlink: stat.isSymbolicLink(),
atimeMs: stat.atimeMs,
mtimeMs: stat.atimeMs,
ctimeMs: stat.atimeMs,
Expand Down

0 comments on commit a888835

Please sign in to comment.