@lvce-editor/search-process 5.1.0 → 5.2.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/dist/index.js +13 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { object, string, array, number } from '@lvce-editor/assert';
|
|
2
2
|
import { NodeWebSocketRpcClient, ElectronMessagePortRpcClient, ElectronUtilityProcessRpcClient, NodeWorkerRpcClient, NodeForkedProcessRpcClient } from '@lvce-editor/rpc';
|
|
3
|
+
import { rgPath } from '@lvce-editor/ripgrep';
|
|
3
4
|
import { Console } from 'node:console';
|
|
4
5
|
import { createWriteStream } from 'node:fs';
|
|
5
6
|
import { tmpdir } from 'node:os';
|
|
6
7
|
import * as NodeChildProcess from 'node:child_process';
|
|
7
8
|
import { execa } from 'execa';
|
|
8
|
-
import { rgPath } from '@lvce-editor/ripgrep';
|
|
9
9
|
import { VError } from '@lvce-editor/verror';
|
|
10
10
|
import { Writable } from 'node:stream';
|
|
11
11
|
import { pipeline } from 'node:stream/promises';
|
|
@@ -15,10 +15,7 @@ const NodeForkedProcess = 2;
|
|
|
15
15
|
const ElectronUtilityProcess = 3;
|
|
16
16
|
const ElectronMessagePort = 4;
|
|
17
17
|
const WebSocket = 6;
|
|
18
|
-
const Auto =
|
|
19
|
-
const {
|
|
20
|
-
argv
|
|
21
|
-
} = process;
|
|
18
|
+
const Auto = argv => {
|
|
22
19
|
if (argv.includes('--ipc-type=node-worker')) {
|
|
23
20
|
return NodeWorker;
|
|
24
21
|
}
|
|
@@ -28,7 +25,7 @@ const Auto = () => {
|
|
|
28
25
|
if (argv.includes('--ipc-type=electron-utility-process')) {
|
|
29
26
|
return ElectronUtilityProcess;
|
|
30
27
|
}
|
|
31
|
-
throw new Error(`[
|
|
28
|
+
throw new Error(`[search-process] unknown ipc type`);
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
const getModule = method => {
|
|
@@ -76,6 +73,12 @@ const handleWebSocket = async (handle, request) => {
|
|
|
76
73
|
});
|
|
77
74
|
};
|
|
78
75
|
|
|
76
|
+
const getRipGrepPath = () => {
|
|
77
|
+
return process.env.RIP_GREP_PATH;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const ripGrepPath = getRipGrepPath() || rgPath;
|
|
81
|
+
|
|
79
82
|
const EmptyString = '';
|
|
80
83
|
const NewLine = '\n';
|
|
81
84
|
|
|
@@ -144,10 +147,6 @@ const error = (...args) => {
|
|
|
144
147
|
console.error(...args);
|
|
145
148
|
};
|
|
146
149
|
|
|
147
|
-
const getRipGrepPath = () => {
|
|
148
|
-
return process.env.RIP_GREP_PATH;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
150
|
const exec$1 = async (command, args, options) => {
|
|
152
151
|
string(command);
|
|
153
152
|
array(args);
|
|
@@ -162,10 +161,9 @@ const exec$1 = async (command, args, options) => {
|
|
|
162
161
|
};
|
|
163
162
|
};
|
|
164
163
|
|
|
165
|
-
const ripGrepPath = getRipGrepPath() || rgPath;
|
|
166
164
|
const spawn = (args, options) => {
|
|
167
165
|
try {
|
|
168
|
-
const childProcess = NodeChildProcess.spawn(
|
|
166
|
+
const childProcess = NodeChildProcess.spawn(ripGrepPath, args, options);
|
|
169
167
|
return {
|
|
170
168
|
childProcess,
|
|
171
169
|
on(event, listener) {
|
|
@@ -454,15 +452,15 @@ const commandMap = {
|
|
|
454
452
|
'TextSearch.search': search
|
|
455
453
|
};
|
|
456
454
|
|
|
457
|
-
const listen = async
|
|
455
|
+
const listen = async argv => {
|
|
458
456
|
await listen$1({
|
|
459
|
-
method: Auto(),
|
|
457
|
+
method: Auto(argv),
|
|
460
458
|
commandMap: commandMap
|
|
461
459
|
});
|
|
462
460
|
};
|
|
463
461
|
|
|
464
462
|
const main = async () => {
|
|
465
|
-
await listen();
|
|
463
|
+
await listen(process.argv);
|
|
466
464
|
};
|
|
467
465
|
|
|
468
466
|
main();
|