zen-fs-config 0.3.9 → 0.3.11

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) {
@@ -349,9 +359,10 @@ async function wrapZenFSFileSystem(config) {
349
359
  },
350
360
  async stat(path, ..._args) {
351
361
  const st = await isolatedFS.stat(path);
362
+ const isDir = typeof st.isDirectory === "function" ? st.isDirectory() : st.mode !== void 0 && (st.mode & 61440) === 16384;
352
363
  return {
353
- isFile: () => st.isDirectory?.() === false || st.mode !== void 0 && (st.mode & 61440) === 32768,
354
- isDirectory: () => st.isDirectory?.() === true || st.mode !== void 0 && (st.mode & 61440) === 16384,
364
+ isFile: () => !isDir,
365
+ isDirectory: () => isDir,
355
366
  size: st.size,
356
367
  mtime: st.mtimeMs ?? st.mtime
357
368
  };
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) {
@@ -302,9 +312,10 @@ async function wrapZenFSFileSystem(config) {
302
312
  },
303
313
  async stat(path, ..._args) {
304
314
  const st = await isolatedFS.stat(path);
315
+ const isDir = typeof st.isDirectory === "function" ? st.isDirectory() : st.mode !== void 0 && (st.mode & 61440) === 16384;
305
316
  return {
306
- isFile: () => st.isDirectory?.() === false || st.mode !== void 0 && (st.mode & 61440) === 32768,
307
- isDirectory: () => st.isDirectory?.() === true || st.mode !== void 0 && (st.mode & 61440) === 16384,
317
+ isFile: () => !isDir,
318
+ isDirectory: () => isDir,
308
319
  size: st.size,
309
320
  mtime: st.mtimeMs ?? st.mtime
310
321
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
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",