Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectoryOptions - mtime does not get used #333

Open
viyaha opened this issue Jul 22, 2021 · 0 comments
Open

DirectoryOptions - mtime does not get used #333

viyaha opened this issue Jul 22, 2021 · 0 comments

Comments

@viyaha
Copy link

viyaha commented Jul 22, 2021

Setup:

Node: 14.17.1
mock-fs: 5.0.0

Specification of the mtime in a directory call gets ignored, all other timestamps are working as expected.

import { statSync } from "fs";
import mock from "mock-fs";
import { directory, file } from "mock-fs/lib/filesystem";


mock({
    "C:\\test": directory({mtime: new Date(1), ctime: new Date(1), atime: new Date(1), birthtime: new Date(1)}),
    "C:\\test\\test.txt": file({mtime: new Date(1), ctime: new Date(1), atime: new Date(1), birthtime: new Date(1)}),
});

console.log(statSync("C:\\test"));
console.log(statSync("C:\\test\\test.txt"));

Result:

Stats {
  dev: 8675309,
  mode: 16895,
  nlink: 2,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: 4096,
  ino: 10,
  size: 1,
  blocks: 1,
  atimeMs: 1,
  mtimeMs: 1626956851865,
  ctimeMs: 1,
  birthtimeMs: 1,
  atime: 1970-01-01T00:00:00.001Z,
  mtime: 2021-07-22T12:27:31.865Z,
  ctime: 1970-01-01T00:00:00.001Z,
  birthtime: 1970-01-01T00:00:00.001Z
}
Stats {
  dev: 8675309,
  mode: 33206,
  nlink: 1,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: 4096,
  ino: 11,
  size: 0,
  blocks: 0,
  atimeMs: 1,
  mtimeMs: 1,
  ctimeMs: 1,
  birthtimeMs: 1,
  atime: 1970-01-01T00:00:00.001Z,
  mtime: 1970-01-01T00:00:00.001Z,
  ctime: 1970-01-01T00:00:00.001Z,
  birthtime: 1970-01-01T00:00:00.001Z
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant