@@ -49,8 +49,14 @@ export async function createFullScan({
4949} ) : Promise < void > {
5050 // Lazily access constants.spinner.
5151 const { spinner } = constants
52- const socketSdk = await setupSdk ( )
53- const supportedFiles = await socketSdk
52+
53+ // We're going to need an api token to suggest data because those suggestions
54+ // must come from data we already know. Don't error on missing api token yet.
55+ // If the api-token is not set, ignore it for the sake of suggestions.
56+ const apiToken = getDefaultToken ( )
57+
58+ const sockSdk = await setupSdk ( apiToken )
59+ const supportedFiles = await sockSdk
5460 . getReportSupportedFiles ( )
5561 . then ( res => {
5662 if ( ! res . success ) {
@@ -88,25 +94,22 @@ export async function createFullScan({
8894 // socketConfig
8995 )
9096
91- // We're going to need an api token to suggest data because those suggestions
92- // must come from data we already know. Don't error on missing api token yet.
93- // If the api-token is not set, ignore it for the sake of suggestions.
94- const apiToken = getDefaultToken ( )
95-
9697 // If the current cwd is unknown and is used as a repo slug anyways, we will
9798 // first need to register the slug before we can use it.
9899 let repoDefaultBranch = ''
99100
100101 if ( apiToken ) {
101102 if ( ! orgSlug ) {
102- const suggestion = await suggestOrgSlug ( socketSdk )
103- if ( suggestion ) orgSlug = suggestion
103+ const suggestion = await suggestOrgSlug ( sockSdk )
104+ if ( suggestion ) {
105+ orgSlug = suggestion
106+ }
104107 updatedInput = true
105108 }
106109
107110 // (Don't bother asking for the rest if we didn't get an org slug above)
108111 if ( orgSlug && ! repoName ) {
109- const suggestion = await suggestRepoSlug ( socketSdk , orgSlug )
112+ const suggestion = await suggestRepoSlug ( sockSdk , orgSlug )
110113 if ( suggestion ) {
111114 repoDefaultBranch = suggestion . defaultBranch
112115 repoName = suggestion . slug
@@ -117,7 +120,9 @@ export async function createFullScan({
117120 // (Don't bother asking for the rest if we didn't get an org/repo above)
118121 if ( orgSlug && repoName && ! branchName ) {
119122 const suggestion = await suggestBranchSlug ( repoDefaultBranch )
120- if ( suggestion ) branchName = suggestion
123+ if ( suggestion ) {
124+ branchName = suggestion
125+ }
121126 updatedInput = true
122127 }
123128 }
@@ -180,7 +185,7 @@ export async function createFullScan({
180185 spinner . start ( `Creating a scan with ${ packagePaths . length } packages...` )
181186
182187 const result = await handleApiCall (
183- socketSdk . createOrgFullScan (
188+ sockSdk . createOrgFullScan (
184189 orgSlug ,
185190 {
186191 repo : repoName ,
0 commit comments