@netlify/build 18.21.2 → 18.21.3

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": "@netlify/build",
3
- "version": "18.21.2",
3
+ "version": "18.21.3",
4
4
  "description": "Netlify build module",
5
5
  "main": "src/core/main.js",
6
6
  "types": "types/index.d.ts",
@@ -1,16 +1,26 @@
1
1
  'use strict'
2
2
 
3
- // Ensure error is an `Error` instance
3
+ // Ensure error is an `Error` instance.
4
+ // If is an `Error` instance but is missing usual `Error` properties, we make
5
+ // sure its static properties are preserved.
4
6
  const normalizeError = function (error) {
5
7
  if (Array.isArray(error)) {
6
8
  return normalizeArray(error)
7
9
  }
8
10
 
9
- if (error instanceof Error && typeof error.message === 'string' && typeof error.stack === 'string') {
10
- return error
11
+ if (!(error instanceof Error)) {
12
+ return new Error(String(error))
11
13
  }
12
14
 
13
- return new Error(String(error))
15
+ if (typeof error.message !== 'string') {
16
+ error.message = String(error)
17
+ }
18
+
19
+ if (typeof error.stack !== 'string') {
20
+ Error.captureStackTrace(error, normalizeError)
21
+ }
22
+
23
+ return error
14
24
  }
15
25
 
16
26
  // Some libraries throw arrays of Errors