@sanity/pkg-utils 6.10.4 → 6.10.5
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/_chunks-cjs/check.cjs +11 -3
- package/dist/_chunks-cjs/check.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/node/check.ts +37 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.10.
|
|
3
|
+
"version": "6.10.5",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"typescript": "5.5.3",
|
|
147
147
|
"vitest": "^2.0.2",
|
|
148
148
|
"vitest-github-actions-reporter": "^0.11.1",
|
|
149
|
-
"@sanity/pkg-utils": "6.10.
|
|
149
|
+
"@sanity/pkg-utils": "6.10.5"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"typescript": "5.4.x || 5.5.x"
|
package/src/node/check.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
|
-
import esbuild, {type BuildFailure} from 'esbuild'
|
|
3
|
+
import esbuild, {type BuildFailure, type Message} from 'esbuild'
|
|
4
4
|
|
|
5
5
|
import {createConsoleSpy} from './consoleSpy'
|
|
6
6
|
import {loadConfig, loadPkgWithReporting} from './core'
|
|
@@ -130,10 +130,20 @@ async function checkExports(
|
|
|
130
130
|
logger.log()
|
|
131
131
|
}
|
|
132
132
|
} catch (err) {
|
|
133
|
-
|
|
133
|
+
if (isEsbuildFailure(err)) {
|
|
134
|
+
const {errors} = err
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
for (const msg of errors) {
|
|
137
|
+
printEsbuildMessage(logger.error, msg)
|
|
138
|
+
|
|
139
|
+
logger.log()
|
|
140
|
+
}
|
|
141
|
+
} else if (err instanceof Error) {
|
|
142
|
+
logger.error(err.stack || err.message)
|
|
143
|
+
|
|
144
|
+
logger.log()
|
|
145
|
+
} else {
|
|
146
|
+
logger.error(`${err}`)
|
|
137
147
|
|
|
138
148
|
logger.log()
|
|
139
149
|
}
|
|
@@ -155,3 +165,26 @@ function printEsbuildMessage(log: (...args: unknown[]) => void, msg: esbuild.Mes
|
|
|
155
165
|
log(msg.detail || msg.text)
|
|
156
166
|
}
|
|
157
167
|
}
|
|
168
|
+
|
|
169
|
+
function isEsbuildFailure(err: unknown): err is BuildFailure {
|
|
170
|
+
return (
|
|
171
|
+
err instanceof Error &&
|
|
172
|
+
'errors' in err &&
|
|
173
|
+
Array.isArray(err.errors) &&
|
|
174
|
+
err.errors.every(isEsbuildMessage) &&
|
|
175
|
+
'warnings' in err &&
|
|
176
|
+
Array.isArray(err.warnings) &&
|
|
177
|
+
err.warnings.every(isEsbuildMessage)
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isEsbuildMessage(msg: unknown): msg is Message {
|
|
182
|
+
return (
|
|
183
|
+
typeof msg === 'object' &&
|
|
184
|
+
msg !== null &&
|
|
185
|
+
'text' in msg &&
|
|
186
|
+
typeof msg.text === 'string' &&
|
|
187
|
+
'location' in msg &&
|
|
188
|
+
(msg.location === null || typeof msg.location === 'object')
|
|
189
|
+
)
|
|
190
|
+
}
|