@lvce-editor/json-rpc 5.4.0 → 6.0.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
@@ -234,6 +234,17 @@ const getErrorType = prettyError => {
234
234
  return undefined;
235
235
  };
236
236
 
237
+ const isAlreadyStack = line => {
238
+ return line.trim().startsWith('at ');
239
+ };
240
+ const getStack = prettyError => {
241
+ const stackString = prettyError.stack || '';
242
+ const newLineIndex = stackString.indexOf('\n');
243
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
244
+ return stackString.slice(newLineIndex + 1);
245
+ }
246
+ return stackString;
247
+ };
237
248
  const getErrorProperty = (error, prettyError) => {
238
249
  if (error && error.code === E_COMMAND_NOT_FOUND) {
239
250
  return {
@@ -246,7 +257,7 @@ const getErrorProperty = (error, prettyError) => {
246
257
  code: Custom,
247
258
  message: prettyError.message,
248
259
  data: {
249
- stack: prettyError.stack,
260
+ stack: getStack(prettyError),
250
261
  codeFrame: prettyError.codeFrame,
251
262
  type: getErrorType(prettyError),
252
263
  code: prettyError.code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/json-rpc",
3
- "version": "5.4.0",
3
+ "version": "6.0.0",
4
4
  "description": "JsonRpc implementation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",