@lvce-editor/shared-process 0.16.7 → 0.16.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.16.7",
3
+ "version": "0.16.9",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.22.5",
20
- "@lvce-editor/extension-host": "0.16.7",
21
- "@lvce-editor/extension-host-helper-process": "0.16.7",
22
- "@lvce-editor/pty-host": "0.16.7",
20
+ "@lvce-editor/extension-host": "0.16.9",
21
+ "@lvce-editor/extension-host-helper-process": "0.16.9",
22
+ "@lvce-editor/pty-host": "0.16.9",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -50,6 +50,27 @@ const getModuleSyntaxError = (stderr) => {
50
50
  }
51
51
  }
52
52
 
53
+ const isModuleNotFoundError = (stderr) => {
54
+ if (!stderr) {
55
+ return false
56
+ }
57
+ return stderr.includes('ERR_MODULE_NOT_FOUND')
58
+ }
59
+
60
+ const isModuleNotFoundMessage = (line) => {
61
+ return line.includes('ERR_MODULE_NOT_FOUND')
62
+ }
63
+
64
+ const getModuleNotFoundError = (stderr) => {
65
+ const lines = stderr.split('\n')
66
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage)
67
+ const message = lines[messageIndex]
68
+ return {
69
+ message,
70
+ code: ErrorCodes.ERR_MODULE_NOT_FOUND,
71
+ }
72
+ }
73
+
53
74
  export const getHelpfulChildProcessError = (stdout, stderr) => {
54
75
  if (isUnhelpfulNativeModuleError(stderr)) {
55
76
  return getNativeModuleErrorMessage(stderr)
@@ -57,6 +78,9 @@ export const getHelpfulChildProcessError = (stdout, stderr) => {
57
78
  if (isModulesSyntaxError(stderr)) {
58
79
  return getModuleSyntaxError(stderr)
59
80
  }
81
+ if (isModuleNotFoundError(stderr)) {
82
+ return getModuleNotFoundError(stderr)
83
+ }
60
84
  return {
61
85
  message: `child process error: ${stderr}`,
62
86
  code: '',
@@ -169,11 +169,11 @@ export const getSetupName = () => {
169
169
  return 'Lvce-Setup'
170
170
  }
171
171
 
172
- export const version = '0.16.7'
172
+ export const version = '0.16.9'
173
173
 
174
- export const commit = '8f3e750'
174
+ export const commit = 'c1ca266'
175
175
 
176
- export const date = '2023-07-07T12:20:25.000Z'
176
+ export const date = '2023-07-08T18:42:12.000Z'
177
177
 
178
178
  export const getVersion = () => {
179
179
  return version
@@ -1,43 +0,0 @@
1
- // parse ps output based on vscode https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/ps.ts (License MIT)
2
-
3
- import * as Exec from '../Exec/Exec.js'
4
- import * as SplitLines from '../SplitLines/SplitLines.js'
5
- import * as ParseInt from '../ParseInt/ParseInt.js'
6
-
7
- const PID_CMD = /^\s*(\d+)\s+(\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(.+)$/
8
-
9
- const parsePsOutputLine = (line) => {
10
- const matches = PID_CMD.exec(line.trim())
11
- if (matches && matches.length === 6) {
12
- return {
13
- pid: ParseInt.parseInt(matches[1]),
14
- ppid: ParseInt.parseInt(matches[2]),
15
- cwd: matches[5],
16
- load: ParseInt.parseInt(matches[3]),
17
- mem: ParseInt.parseInt(matches[4]),
18
- }
19
- }
20
- }
21
- const parsePsOutput = (stdout, rootPid) => {
22
- const lines = SplitLines.splitLines(stdout)
23
- return lines.map(parsePsOutputLine)
24
- }
25
-
26
- const getPsOutput = async (rootPid) => {
27
- const { stdout } = await Exec.exec('ps', ['-g', `${rootPid}`, '-a', '-o', 'pid=,ppid=,pcpu=,pmem=,command='], {
28
- shell: true,
29
- })
30
- return stdout
31
- }
32
-
33
- export const listProcessesWithMemoryUsage = async (rootPid) => {
34
- const stdout = await getPsOutput(rootPid)
35
- const parsed = parsePsOutput(stdout, rootPid)
36
- console.log(parsed)
37
- }
38
-
39
- const main = async () => {
40
- await listProcessesWithMemoryUsage(process.pid)
41
- }
42
-
43
- main()