@k03mad/ip2geo 9.6.0 → 9.7.0

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/app/cli.js CHANGED
@@ -46,7 +46,7 @@ if (isPrune) {
46
46
  log(blue(cacheFolder));
47
47
 
48
48
  try {
49
- const {duplicates, empty, longLinesFiles} = await pruneCache(
49
+ const {duplicates, empty, entries, longLinesFiles} = await pruneCache(
50
50
  cacheFolder,
51
51
  DEFAULT_CACHE_FILE_SEPARATOR,
52
52
  DEFAULT_CACHE_FILE_NEWLINE,
@@ -66,6 +66,11 @@ if (isPrune) {
66
66
  ...longLinesFiles.map(({file, elem}) => dim(`— ${file}\n|— ${elem}`)),
67
67
  ]);
68
68
  }
69
+
70
+ log([
71
+ '',
72
+ green(`Current cache entries: ${bold(entries)}`),
73
+ ]);
69
74
  } catch (err) {
70
75
  logErrorExit(red(err));
71
76
  }
@@ -193,6 +193,7 @@ export const pruneCache = async (cacheDir, cacheFileSeparator, cacheFileNewline)
193
193
  const duplicates = new Set();
194
194
  const empty = [];
195
195
  const longLinesFiles = new Set();
196
+ let entries = 0;
196
197
 
197
198
  await Promise.all(files.map(async file => {
198
199
  const fullFilePath = path.join(cacheDir, file);
@@ -218,13 +219,20 @@ export const pruneCache = async (cacheDir, cacheFileSeparator, cacheFileNewline)
218
219
  .sort((a, b) => cacheLineToNum(a) - cacheLineToNum(b));
219
220
 
220
221
  const fileContent = uniq.join(cacheFileNewline).trim();
221
- await (fileContent ? fs.writeFile(fullFilePath, fileContent) : fs.rm(fullFilePath));
222
+
223
+ if (fileContent) {
224
+ await fs.writeFile(fullFilePath, fileContent);
225
+ entries += uniq.length;
226
+ } else {
227
+ await fs.rm(fullFilePath);
228
+ }
222
229
 
223
230
  dataArrRemoveEmpty
224
231
  .forEach((elem, i, arr) => arr.indexOf(elem) !== i && duplicates.add(elem));
225
232
  }));
226
233
 
227
234
  return {
235
+ entries,
228
236
  duplicates: [...duplicates],
229
237
  empty,
230
238
  longLinesFiles: [...longLinesFiles],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/ip2geo",
3
- "version": "9.6.0",
3
+ "version": "9.7.0",
4
4
  "description": "GeoIP library",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"