Skip to content

Commit 8fb24fd

Browse files
committed
Cleanup writing dep-stats
1 parent cbc0a34 commit 8fb24fd

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

.config/rollup.dist.config.mjs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
2121

2222
import baseConfig from './rollup.base.config.mjs'
2323
import constants from '../scripts/constants.js'
24-
import { formatObject } from '../scripts/utils/objects.js'
2524
import {
2625
getPackageName,
2726
isBuiltin,
@@ -165,6 +164,8 @@ async function updateDepStats(depStats) {
165164
)
166165
)
167166
)
167+
// Remove Sentry as a direct dependency by default.
168+
delete depStats.dependencies[SENTRY_NODE]
168169
// Remove transitives from dependencies.
169170
for (const key of Object.keys(oldDepStats?.transitives ?? {})) {
170171
if (pkgJson.dependencies[key]) {
@@ -173,20 +174,18 @@ async function updateDepStats(depStats) {
173174
delete depStats.dependencies[key]
174175
}
175176
}
177+
// Lazily access constants.ENV[SOCKET_IS_SENTRY_BUILD].
178+
if (constants.ENV[SOCKET_IS_SENTRY_BUILD]) {
179+
// Add Sentry as a direct dependency for this build.
180+
depStats.dependencies[SENTRY_NODE] = (await getSentryManifest()).version
181+
}
176182
depStats.dependencies = toSortedObject(depStats.dependencies)
177183
depStats.devDependencies = toSortedObject(depStats.devDependencies)
178184
depStats.esm = toSortedObject(depStats.esm)
179185
depStats.external = toSortedObject(depStats.external)
180186
depStats.transitives = toSortedObject(depStats.transitives)
181-
// Lazily access constants.ENV[SOCKET_IS_SENTRY_BUILD].
182-
if (constants.ENV[SOCKET_IS_SENTRY_BUILD]) {
183-
// Add Sentry as a regular dep for this build.
184-
depStats.dependencies[SENTRY_NODE] = (await getSentryManifest()).version
185-
} else {
186-
delete depStats.dependencies[SENTRY_NODE]
187-
}
188187
// Write dep stats.
189-
await fs.writeFile(depStatsPath, `${formatObject(depStats)}\n`, 'utf8')
188+
await writeJson(depStatsPath, toSortedObject(depStats), { spaces: 2 })
190189
// Update dependencies with additional inlined modules.
191190
editablePkgJson.update({
192191
dependencies: {

scripts/utils/objects.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)