@@ -86,19 +86,20 @@ ${debugFlagMessage}`,
8686 }
8787 }
8888
89- async function prepareAsset ( file ) {
89+ async function prepareAsset ( file , options = { } ) {
9090 let filePath ;
9191 spinner . text = 'Preparing asset' ;
9292 try {
9393 filePath = resolve ( file ) ;
9494 debug ( `Reading file from ${ filePath } ` ) ;
9595 const assetContent = await readFile ( filePath ) ;
9696 const path = `${ encodeURIComponent ( basename ( filePath ) ) } ` ;
97+ const access = options . access || 'public' ;
9798 const newAsset = {
99+ content : assetContent ,
98100 name : path ,
99- access : 'public' ,
100101 path,
101- content : assetContent ,
102+ access ,
102103 } ;
103104 return newAsset ;
104105 } catch ( error ) {
@@ -149,7 +150,7 @@ ${debugFlagMessage}`,
149150 ] ) ;
150151 let newName = newNameAnswers . newName . trim ( ) ;
151152 while (
152- existingAssets . find ( asset => asset . friendly_name === newName ) ||
153+ existingAssets . find ( ( asset ) => asset . friendly_name === newName ) ||
153154 newName === ''
154155 ) {
155156 const message =
@@ -244,7 +245,7 @@ ${debugFlagMessage}`,
244245 async function waitForBuild ( buildSid , serviceSid , client ) {
245246 try {
246247 const updateHandler = new EventEmitter ( ) ;
247- updateHandler . on ( 'status-update' , update => debug ( update . message ) ) ;
248+ updateHandler . on ( 'status-update' , ( update ) => debug ( update . message ) ) ;
248249 await waitForSuccessfulBuild ( buildSid , serviceSid , client , updateHandler ) ;
249250 } catch ( error ) {
250251 handleError (
@@ -298,6 +299,7 @@ async function upload({
298299 accountSid,
299300 file,
300301 logger,
302+ visibility,
301303} ) {
302304 const spinner = ora ( {
303305 isSilent : logger . config . level > 0 ,
@@ -337,10 +339,10 @@ async function upload({
337339 accountSid
338340 ) ;
339341 await checkServiceForFunctions ( client , serviceSid ) ;
340- let newAsset = await prepareAsset ( file ) ;
342+ let newAsset = await prepareAsset ( file , { access : visibility } ) ;
341343 const existingAssets = await getExistingAssets ( client , serviceSid ) ;
342344 const existingAsset = existingAssets . find (
343- asset => asset . friendly_name === newAsset . name
345+ ( asset ) => asset . friendly_name === newAsset . name
344346 ) ;
345347 if ( existingAsset ) {
346348 newAsset = await overwriteRenameOrAbort (
@@ -367,8 +369,8 @@ async function upload({
367369 client
368370 ) ;
369371 existingAssetVersions
370- . filter ( av => av . asset_sid !== assetVersion . asset_sid )
371- . forEach ( assetVersion => assetVersions . push ( assetVersion . sid ) ) ;
372+ . filter ( ( av ) => av . asset_sid !== assetVersion . asset_sid )
373+ . forEach ( ( assetVersion ) => assetVersions . push ( assetVersion . sid ) ) ;
372374 }
373375 const build = await triggerNewBuild (
374376 Array . from ( assetVersions ) ,
0 commit comments