file-entry-cache 10.0.1 → 10.0.3

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.cjs CHANGED
@@ -59,7 +59,6 @@ function create(cacheId, cacheDirectory, useCheckSum, currentWorkingDirectory) {
59
59
  const cachePath = `${cacheDirectory}/${cacheId}`;
60
60
  if (import_node_fs.default.existsSync(cachePath)) {
61
61
  fileEntryCache.cache = (0, import_flat_cache.createFromFile)(cachePath, options.cache);
62
- fileEntryCache.reconcile();
63
62
  }
64
63
  }
65
64
  return fileEntryCache;
@@ -69,7 +68,7 @@ var FileEntryDefault = class {
69
68
  static createFromFile = createFromFile;
70
69
  };
71
70
  var FileEntryCache = class {
72
- _cache = new import_flat_cache.FlatCache();
71
+ _cache = new import_flat_cache.FlatCache({ useClone: false });
73
72
  _useCheckSum = false;
74
73
  _currentWorkingDirectory;
75
74
  _hashAlgorithm = "md5";
@@ -220,6 +219,7 @@ var FileEntryCache = class {
220
219
  changed: false,
221
220
  meta: {}
222
221
  };
222
+ result.meta = this._cache.getKey(result.key) ?? {};
223
223
  filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
224
224
  const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum;
225
225
  try {
@@ -251,15 +251,19 @@ var FileEntryCache = class {
251
251
  this._cache.setKey(result.key, result.meta);
252
252
  return result;
253
253
  }
254
- result.meta.data = metaCache.data;
254
+ if (result.meta.data !== metaCache.data) {
255
+ result.changed = true;
256
+ }
257
+ if (result.meta.data === void 0) {
258
+ result.meta.data = metaCache.data;
259
+ }
255
260
  if (metaCache?.mtime !== result.meta?.mtime || metaCache?.size !== result.meta?.size) {
256
261
  result.changed = true;
257
- this._cache.setKey(result.key, result.meta);
258
262
  }
259
263
  if (useCheckSumValue && metaCache?.hash !== result.meta?.hash) {
260
264
  result.changed = true;
261
- this._cache.setKey(result.key, result.meta);
262
265
  }
266
+ this._cache.setKey(result.key, result.meta);
263
267
  return result;
264
268
  }
265
269
  /**
package/dist/index.js CHANGED
@@ -22,7 +22,6 @@ function create(cacheId, cacheDirectory, useCheckSum, currentWorkingDirectory) {
22
22
  const cachePath = `${cacheDirectory}/${cacheId}`;
23
23
  if (fs.existsSync(cachePath)) {
24
24
  fileEntryCache.cache = createFlatCacheFile(cachePath, options.cache);
25
- fileEntryCache.reconcile();
26
25
  }
27
26
  }
28
27
  return fileEntryCache;
@@ -32,7 +31,7 @@ var FileEntryDefault = class {
32
31
  static createFromFile = createFromFile;
33
32
  };
34
33
  var FileEntryCache = class {
35
- _cache = new FlatCache();
34
+ _cache = new FlatCache({ useClone: false });
36
35
  _useCheckSum = false;
37
36
  _currentWorkingDirectory;
38
37
  _hashAlgorithm = "md5";
@@ -183,6 +182,7 @@ var FileEntryCache = class {
183
182
  changed: false,
184
183
  meta: {}
185
184
  };
185
+ result.meta = this._cache.getKey(result.key) ?? {};
186
186
  filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
187
187
  const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum;
188
188
  try {
@@ -214,15 +214,19 @@ var FileEntryCache = class {
214
214
  this._cache.setKey(result.key, result.meta);
215
215
  return result;
216
216
  }
217
- result.meta.data = metaCache.data;
217
+ if (result.meta.data !== metaCache.data) {
218
+ result.changed = true;
219
+ }
220
+ if (result.meta.data === void 0) {
221
+ result.meta.data = metaCache.data;
222
+ }
218
223
  if (metaCache?.mtime !== result.meta?.mtime || metaCache?.size !== result.meta?.size) {
219
224
  result.changed = true;
220
- this._cache.setKey(result.key, result.meta);
221
225
  }
222
226
  if (useCheckSumValue && metaCache?.hash !== result.meta?.hash) {
223
227
  result.changed = true;
224
- this._cache.setKey(result.key, result.meta);
225
228
  }
229
+ this._cache.setKey(result.key, result.meta);
226
230
  return result;
227
231
  }
228
232
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-entry-cache",
3
- "version": "10.0.1",
3
+ "version": "10.0.3",
4
4
  "description": "A lightweight cache for file metadata, ideal for processes that work on a specific set of files and only need to reprocess files that have changed since the last run",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -29,16 +29,16 @@
29
29
  "cache"
30
30
  ],
31
31
  "devDependencies": {
32
- "@types/node": "^22.8.1",
33
- "@vitest/coverage-v8": "^2.1.3",
32
+ "@types/node": "^22.9.3",
33
+ "@vitest/coverage-v8": "^2.1.5",
34
34
  "rimraf": "^6.0.1",
35
35
  "tsup": "^8.3.5",
36
- "typescript": "^5.6.3",
37
- "vitest": "^2.1.3",
36
+ "typescript": "^5.7.2",
37
+ "vitest": "^2.1.5",
38
38
  "xo": "^0.59.3"
39
39
  },
40
40
  "dependencies": {
41
- "flat-cache": "^6.1.1"
41
+ "flat-cache": "^6.1.2"
42
42
  },
43
43
  "files": [
44
44
  "dist",