@lvce-editor/search-process 15.9.0 → 15.11.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.
Files changed (2) hide show
  1. package/dist/index.js +12 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { rgPath } from '@lvce-editor/ripgrep';
2
3
  import { fileURLToPath } from 'node:url';
3
4
  import { Console } from 'node:console';
@@ -1537,6 +1538,7 @@ const exec = execRipGrep;
1537
1538
  // but the second time only a few hundred bytes of changes
1538
1539
 
1539
1540
  const searchFile = async ({
1541
+ ifNonMatch,
1540
1542
  limit = 100,
1541
1543
  ripGrepArgs = [],
1542
1544
  searchPath = ''
@@ -1551,7 +1553,16 @@ const searchFile = async ({
1551
1553
  } = await exec(ripGrepArgs, {
1552
1554
  cwd
1553
1555
  });
1554
- return limitString(stdout, limit);
1556
+ const results = limitString(stdout, limit);
1557
+ if (ifNonMatch === undefined) {
1558
+ return results;
1559
+ }
1560
+ const hash = createHash('sha256').update(searchPath).update('\0').update(JSON.stringify(ripGrepArgs)).update('\0').update(results).digest('hex');
1561
+ return {
1562
+ hash,
1563
+ matchesCache: hash === ifNonMatch,
1564
+ results: hash === ifNonMatch ? '' : results
1565
+ };
1555
1566
  } catch (error$1) {
1556
1567
  if (isEnoentError(error$1)) {
1557
1568
  info(`[search-process] ripgrep could not be found at "${ripGrepPath}"`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/search-process",
3
- "version": "15.9.0",
3
+ "version": "15.11.0",
4
4
  "description": "Search Process",
5
5
  "keywords": [
6
6
  "Lvce Editor",