zen-fs-config 0.3.10 → 0.3.12

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/dist/index.js CHANGED
@@ -147,7 +147,16 @@ function createChrootFS(inner, root) {
147
147
  return inner.readdir(rp(path));
148
148
  },
149
149
  async stat(path) {
150
- return inner.stat(rp(path));
150
+ const s = await inner.stat(rp(path));
151
+ if (typeof s.isFile === "function" && typeof s.isDirectory === "function") {
152
+ return s;
153
+ }
154
+ const isDir = typeof s.isDirectory === "function" ? s.isDirectory() : typeof s.isDirectory === "boolean" ? s.isDirectory : s.mode !== void 0 && (s.mode & 61440) === 16384;
155
+ return {
156
+ ...s,
157
+ isFile: () => !isDir,
158
+ isDirectory: () => isDir
159
+ };
151
160
  },
152
161
  async access(path) {
153
162
  const exists = await inner.exists(rp(path));
@@ -280,11 +289,12 @@ function cachedFSToSyncableFS(cached) {
280
289
  },
281
290
  async stat(path) {
282
291
  const s = await cached.stat(path);
292
+ const isDir = typeof s.isDirectory === "function" ? s.isDirectory() : typeof s.isDirectory === "boolean" ? s.isDirectory : s.mode !== void 0 && (s.mode & 61440) === 16384;
283
293
  return {
284
- isFile: () => s.isFile(),
285
- isDirectory: () => s.isDirectory(),
294
+ isFile: () => !isDir,
295
+ isDirectory: () => isDir,
286
296
  size: s.size,
287
- mtimeMs: s.mtimeMs
297
+ mtimeMs: s.mtimeMs ?? s.mtime
288
298
  };
289
299
  },
290
300
  async mkdir(path, options) {
@@ -343,6 +353,7 @@ async function wrapZenFSFileSystem(config) {
343
353
  await isolatedFS.createFile(path, { uid: 0, gid: 0, mode: 420 });
344
354
  }
345
355
  await isolatedFS.write(path, bytes, 0);
356
+ await isolatedFS.touch(path, { size: bytes.byteLength, mtimeMs: Date.now() });
346
357
  },
347
358
  async readdir(path) {
348
359
  return isolatedFS.readdir(path);
package/dist/index.mjs CHANGED
@@ -100,7 +100,16 @@ function createChrootFS(inner, root) {
100
100
  return inner.readdir(rp(path));
101
101
  },
102
102
  async stat(path) {
103
- return inner.stat(rp(path));
103
+ const s = await inner.stat(rp(path));
104
+ if (typeof s.isFile === "function" && typeof s.isDirectory === "function") {
105
+ return s;
106
+ }
107
+ const isDir = typeof s.isDirectory === "function" ? s.isDirectory() : typeof s.isDirectory === "boolean" ? s.isDirectory : s.mode !== void 0 && (s.mode & 61440) === 16384;
108
+ return {
109
+ ...s,
110
+ isFile: () => !isDir,
111
+ isDirectory: () => isDir
112
+ };
104
113
  },
105
114
  async access(path) {
106
115
  const exists = await inner.exists(rp(path));
@@ -233,11 +242,12 @@ function cachedFSToSyncableFS(cached) {
233
242
  },
234
243
  async stat(path) {
235
244
  const s = await cached.stat(path);
245
+ const isDir = typeof s.isDirectory === "function" ? s.isDirectory() : typeof s.isDirectory === "boolean" ? s.isDirectory : s.mode !== void 0 && (s.mode & 61440) === 16384;
236
246
  return {
237
- isFile: () => s.isFile(),
238
- isDirectory: () => s.isDirectory(),
247
+ isFile: () => !isDir,
248
+ isDirectory: () => isDir,
239
249
  size: s.size,
240
- mtimeMs: s.mtimeMs
250
+ mtimeMs: s.mtimeMs ?? s.mtime
241
251
  };
242
252
  },
243
253
  async mkdir(path, options) {
@@ -296,6 +306,7 @@ async function wrapZenFSFileSystem(config) {
296
306
  await isolatedFS.createFile(path, { uid: 0, gid: 0, mode: 420 });
297
307
  }
298
308
  await isolatedFS.write(path, bytes, 0);
309
+ await isolatedFS.touch(path, { size: bytes.byteLength, mtimeMs: Date.now() });
299
310
  },
300
311
  async readdir(path) {
301
312
  return isolatedFS.readdir(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",