Skip to content

Commit 9f49fa7

Browse files
committed
update the stream functionality
1 parent 868905c commit 9f49fa7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lib/commands/fullscans/stream.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export const stream = {
1717

1818
const input = setupCommand(name, stream.description, argv, importMeta)
1919
if (input) {
20-
const spinnerText = 'Streaming full scan...'
20+
const spinnerText = 'Streaming full scan... \n'
2121
const spinner = ora(spinnerText).start()
22-
await getOrgFullScan(input.orgSlug, input.fullScanId, spinner)
22+
await getOrgFullScan(input.orgSlug, input.fullScanId, input.file, spinner)
2323
}
2424
}
2525
}
@@ -32,6 +32,7 @@ export const stream = {
3232
* @property {boolean} outputMarkdown
3333
* @property {string} orgSlug
3434
* @property {string} fullScanId
35+
* @property {string | undefined} file
3536
*/
3637

3738
/**
@@ -48,13 +49,13 @@ function setupCommand (name, description, argv, importMeta) {
4849

4950
const cli = meow(`
5051
Usage
51-
$ ${name} <org slug> <full scan ID>
52+
$ ${name} <org slug> <full scan ID> <file>
5253
5354
Options
5455
${printFlagList(flags, 6)}
5556
5657
Examples
57-
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
58+
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
5859
`, {
5960
argv,
6061
description,
@@ -73,12 +74,14 @@ function setupCommand (name, description, argv, importMeta) {
7374

7475
const orgSlug = cli.input[0] || ''
7576
const fullScanId = cli.input[1] || ''
77+
const file = cli.input[2]
7678

7779
return {
7880
outputJson,
7981
outputMarkdown,
8082
orgSlug,
81-
fullScanId
83+
fullScanId,
84+
file
8285
}
8386
}
8487

@@ -90,21 +93,23 @@ function setupCommand (name, description, argv, importMeta) {
9093
/**
9194
* @param {string} orgSlug
9295
* @param {string} fullScanId
96+
* @param {string|undefined} file
9397
* @param {import('ora').Ora} spinner
9498
* @returns {Promise<void|FullScanData>}
9599
*/
96-
async function getOrgFullScan (orgSlug, fullScanId, spinner) {
100+
async function getOrgFullScan (orgSlug, fullScanId, file, spinner) {
97101
const socketSdk = await setupSdk(getDefaultKey())
98-
const result = await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId), 'Streaming a full scan')
102+
// @ts-ignore
103+
const result = await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a full scan')
99104

100-
if (!result.success) {
105+
if (!result?.success) {
101106
return handleUnsuccessfulApiResponse('getOrgFullScan', result, spinner)
102107
}
103108

104-
console.log('\n Full scan details: \n')
105-
106109
spinner.stop()
107110

111+
console.log(file ? `\nFull scan details written to ${file} \n` : '\nFull scan details: \n')
112+
108113
return {
109114
data: result.data
110115
}

0 commit comments

Comments
 (0)