almostnode 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/virtual-fs.ts CHANGED
@@ -8,6 +8,7 @@ export interface FSNode {
8
8
  type: 'file' | 'directory';
9
9
  content?: Uint8Array;
10
10
  children?: Map<string, FSNode>;
11
+ mtime: number;
11
12
  }
12
13
 
13
14
  // Simple EventEmitter for VFS change notifications
@@ -111,6 +112,7 @@ export class VirtualFS {
111
112
  this.root = {
112
113
  type: 'directory',
113
114
  children: new Map(),
115
+ mtime: Date.now(),
114
116
  };
115
117
  }
116
118
 
@@ -252,6 +254,7 @@ export class VirtualFS {
252
254
  parent.children!.set(basename, {
253
255
  type: 'file',
254
256
  content,
257
+ mtime: Date.now(),
255
258
  });
256
259
 
257
260
  if (emitEvent) {
@@ -344,7 +347,7 @@ export class VirtualFS {
344
347
 
345
348
  let child = current.children.get(segment);
346
349
  if (!child) {
347
- child = { type: 'directory', children: new Map() };
350
+ child = { type: 'directory', children: new Map(), mtime: Date.now() };
348
351
  current.children.set(segment, child);
349
352
  } else if (child.type !== 'directory') {
350
353
  throw new Error(`ENOTDIR: not a directory, '${path}'`);
@@ -372,8 +375,8 @@ export class VirtualFS {
372
375
  throw createNodeError('ENOENT', 'stat', path);
373
376
  }
374
377
 
375
- const now = Date.now();
376
378
  const size = node.type === 'file' ? (node.content?.length || 0) : 0;
379
+ const mtime = node.mtime;
377
380
 
378
381
  return {
379
382
  isFile: () => node.type === 'file',
@@ -385,14 +388,14 @@ export class VirtualFS {
385
388
  isSocket: () => false,
386
389
  size,
387
390
  mode: node.type === 'directory' ? 0o755 : 0o644,
388
- mtime: new Date(now),
389
- atime: new Date(now),
390
- ctime: new Date(now),
391
- birthtime: new Date(now),
392
- mtimeMs: now,
393
- atimeMs: now,
394
- ctimeMs: now,
395
- birthtimeMs: now,
391
+ mtime: new Date(mtime),
392
+ atime: new Date(mtime),
393
+ ctime: new Date(mtime),
394
+ birthtime: new Date(mtime),
395
+ mtimeMs: mtime,
396
+ atimeMs: mtime,
397
+ ctimeMs: mtime,
398
+ birthtimeMs: mtime,
396
399
  nlink: 1,
397
400
  uid: 1000,
398
401
  gid: 1000,
@@ -478,6 +481,7 @@ export class VirtualFS {
478
481
  parent.children!.set(basename, {
479
482
  type: 'directory',
480
483
  children: new Map(),
484
+ mtime: Date.now(),
481
485
  });
482
486
  }
483
487