@@ -86,19 +86,20 @@ ${debugFlagMessage}`,
86
86
}
87
87
}
88
88
89
- async function prepareAsset ( file ) {
89
+ async function prepareAsset ( file , options = { } ) {
90
90
let filePath ;
91
91
spinner . text = 'Preparing asset' ;
92
92
try {
93
93
filePath = resolve ( file ) ;
94
94
debug ( `Reading file from ${ filePath } ` ) ;
95
95
const assetContent = await readFile ( filePath ) ;
96
96
const path = `${ encodeURIComponent ( basename ( filePath ) ) } ` ;
97
+ const access = options . access || 'public' ;
97
98
const newAsset = {
99
+ content : assetContent ,
98
100
name : path ,
99
- access : 'public' ,
100
101
path,
101
- content : assetContent ,
102
+ access ,
102
103
} ;
103
104
return newAsset ;
104
105
} catch ( error ) {
@@ -149,7 +150,7 @@ ${debugFlagMessage}`,
149
150
] ) ;
150
151
let newName = newNameAnswers . newName . trim ( ) ;
151
152
while (
152
- existingAssets . find ( asset => asset . friendly_name === newName ) ||
153
+ existingAssets . find ( ( asset ) => asset . friendly_name === newName ) ||
153
154
newName === ''
154
155
) {
155
156
const message =
@@ -244,7 +245,7 @@ ${debugFlagMessage}`,
244
245
async function waitForBuild ( buildSid , serviceSid , client ) {
245
246
try {
246
247
const updateHandler = new EventEmitter ( ) ;
247
- updateHandler . on ( 'status-update' , update => debug ( update . message ) ) ;
248
+ updateHandler . on ( 'status-update' , ( update ) => debug ( update . message ) ) ;
248
249
await waitForSuccessfulBuild ( buildSid , serviceSid , client , updateHandler ) ;
249
250
} catch ( error ) {
250
251
handleError (
@@ -298,6 +299,7 @@ async function upload({
298
299
accountSid,
299
300
file,
300
301
logger,
302
+ visibility,
301
303
} ) {
302
304
const spinner = ora ( {
303
305
isSilent : logger . config . level > 0 ,
@@ -337,10 +339,10 @@ async function upload({
337
339
accountSid
338
340
) ;
339
341
await checkServiceForFunctions ( client , serviceSid ) ;
340
- let newAsset = await prepareAsset ( file ) ;
342
+ let newAsset = await prepareAsset ( file , { access : visibility } ) ;
341
343
const existingAssets = await getExistingAssets ( client , serviceSid ) ;
342
344
const existingAsset = existingAssets . find (
343
- asset => asset . friendly_name === newAsset . name
345
+ ( asset ) => asset . friendly_name === newAsset . name
344
346
) ;
345
347
if ( existingAsset ) {
346
348
newAsset = await overwriteRenameOrAbort (
@@ -367,8 +369,8 @@ async function upload({
367
369
client
368
370
) ;
369
371
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 ) ) ;
372
374
}
373
375
const build = await triggerNewBuild (
374
376
Array . from ( assetVersions ) ,
0 commit comments