Skip to content

Commit 296c43a

Browse files
committed
Cleanup spinner use
1 parent 7c709d3 commit 296c43a

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

src/commands/manifest/convert_gradle_to_maven.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async function execGradleWithSpinner(
113113
logger.info(
114114
'(It will show no output, you can use --verbose to see its output)',
115115
)
116-
spinner.start(`Running gradlew`)
116+
spinner.start(`Running gradlew...`)
117117

118118
const output = await spawn(bin, commandArgs, {
119119
// We can pipe the output through to have the user see the result

src/utils/alerts-map.mts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { logger } from '@socketsecurity/registry/lib/logger'
55
import { extractPurlsFromPnpmLockfile } from './pnpm.mts'
66
import { getPublicToken, setupSdk } from './sdk.mts'
77
import { addArtifactToAlertsMap } from './socket-package-alert.mts'
8-
import constants from '../constants.mts'
98

109
import type { CompactSocketArtifact } from './alert/artifact.mts'
1110
import type {
@@ -121,8 +120,7 @@ export async function getAlertsMapFromPurls(
121120
`Socket API server error (${statusCode}): ${statusMessage}`,
122121
)
123122
} else {
124-
const { spinner } = constants
125-
spinner.stop()
123+
spinner?.stop()
126124
debugFn('Received a result=false:', batchResult)
127125
logger.fail(
128126
`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
@@ -132,9 +130,8 @@ export async function getAlertsMapFromPurls(
132130
break
133131
}
134132
remaining -= 1
135-
if (spinner && remaining > 0) {
136-
spinner.start()
137-
spinner.setText(getText())
133+
if (remaining > 0) {
134+
spinner?.start(getText())
138135
}
139136
}
140137

src/utils/api.mts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,31 +199,25 @@ export async function queryApiSafeText(
199199
}
200200
}
201201

202-
if (fetchSpinnerDesc) {
203-
// Lazily access constants.spinner.
204-
const { spinner } = constants
202+
// Lazily access constants.spinner.
203+
const { spinner } = constants
205204

205+
if (fetchSpinnerDesc) {
206206
spinner.start(`Requesting ${fetchSpinnerDesc} from API...`)
207207
}
208208

209209
let result
210210
try {
211211
result = await queryApi(path, apiToken)
212212
if (fetchSpinnerDesc) {
213-
// Lazily access constants.spinner.
214-
const { spinner } = constants
215-
216213
spinner.successAndStop(
217214
`Received API response (after requesting ${fetchSpinnerDesc}).`,
218215
)
219216
}
220217
} catch (e) {
221218
if (fetchSpinnerDesc) {
222-
// Lazily access constants.spinner.
223-
const { spinner } = constants
224-
225219
spinner.failAndStop(
226-
`An error was thrown while requesting ${fetchSpinnerDesc}`,
220+
`An error was thrown while requesting ${fetchSpinnerDesc}.`,
227221
)
228222
}
229223

0 commit comments

Comments
 (0)