@salesforce/sf-plugins-core 2.2.0 → 2.2.1

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/lib/sfCommand.js +16 -5
  2. package/package.json +1 -1
package/lib/sfCommand.js CHANGED
@@ -255,11 +255,18 @@ class SfCommand extends core_1.Command {
255
255
  }
256
256
  async catch(error) {
257
257
  // transform an unknown error into one that conforms to the interface
258
- const codeFromError = error instanceof core_2.SfError ? error.exitCode : 1;
258
+ // @ts-expect-error because exitCode is not on Error
259
+ const codeFromError = error.exitCode ?? 1;
259
260
  process.exitCode ?? (process.exitCode = codeFromError);
260
- const sfErrorProperties = error instanceof core_2.SfError
261
- ? { data: error.data, actions: error.actions, code: codeFromError, context: error.context }
262
- : {};
261
+ const sfErrorProperties = removeEmpty({
262
+ // @ts-expect-error because data is not on Error
263
+ data: error.data ?? null,
264
+ // @ts-expect-error because actions is not on Error
265
+ actions: error.actions ?? null,
266
+ code: codeFromError,
267
+ // @ts-expect-error because context is not on Error
268
+ context: error.context ?? null,
269
+ });
263
270
  const sfCommandError = {
264
271
  ...sfErrorProperties,
265
272
  ...{
@@ -276,7 +283,7 @@ class SfCommand extends core_1.Command {
276
283
  else {
277
284
  this.logToStderr(this.formatError(sfCommandError));
278
285
  }
279
- return sfCommandError;
286
+ throw sfCommandError;
280
287
  }
281
288
  /**
282
289
  * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
@@ -335,4 +342,8 @@ SfCommand.enableJsonFlag = true;
335
342
  * ```
336
343
  */
337
344
  SfCommand.tableFlags = core_1.ux.table.flags;
345
+ function removeEmpty(obj) {
346
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
347
+ return Object.fromEntries(Object.entries(obj).filter(([_, v]) => v != null));
348
+ }
338
349
  //# sourceMappingURL=sfCommand.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Utils for writing Salesforce CLI plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",