@@ -26,8 +26,8 @@ class Migrater {
2626 'picBed.transformer' : 'base64'
2727 } )
2828 this . ctx . output = [ ] // a bug before picgo v1.2.2
29- const include : string | null = this . ctx . getConfig ( 'picgo-plugin-pic-migrater.include' ) || null
30- const exclude : string | null = this . ctx . getConfig ( 'picgo-plugin-pic-migrater.exclude' ) || null
29+ const include : string | null = this . ctx . getConfig ( 'picgo-plugin-pic-migrater.include' ) ?? ' null'
30+ const exclude : string | null = this . ctx . getConfig ( 'picgo-plugin-pic-migrater.exclude' ) ?? ' null'
3131 const includesReg = new RegExp ( include )
3232 const excludesReg = new RegExp ( exclude )
3333
@@ -42,11 +42,11 @@ class Migrater {
4242 }
4343
4444 const toUploadURLs = this . urlArray . filter ( url => ( ( ! include || includesReg . test ( url ) ) && ( ! exclude || ! excludesReg . test ( url ) ) ) ) . map ( async url => {
45- return await new Promise < IImgInfo > ( async ( resolve , reject ) : Promise < void > => {
45+ return await new Promise < IImgInfo | undefined > ( async ( resolve , reject ) : Promise < void > => {
4646 result . total += 1
4747
4848 try {
49- let imgInfo : IImgInfo
49+ let imgInfo : IImgInfo | undefined
5050 const isUrlPath = isUrl ( url )
5151 if ( isUrlPath ) {
5252 imgInfo = await this . handlePicFromURL ( url )
@@ -70,7 +70,7 @@ class Migrater {
7070 const toUploadImgs = await Promise . all ( toUploadURLs ) . then ( imgs => imgs . filter ( img => img !== undefined ) )
7171
7272 // upload
73- let output = [ ]
73+ let output : IImgInfo [ ] = [ ]
7474 if ( toUploadImgs && toUploadImgs . length > 0 ) {
7575 if ( this . guiApi ) {
7676 output = await this . guiApi . upload ( toUploadImgs )
@@ -91,7 +91,7 @@ class Migrater {
9191 result . urls = output . filter ( item => item . imgUrl && item . imgUrl !== item . origin ) . map ( item => {
9292 return {
9393 original : item . origin ,
94- new : item . imgUrl
94+ new : item . imgUrl as string
9595 }
9696 } )
9797 result . success = result . urls . length
@@ -166,7 +166,7 @@ class Migrater {
166166 fileName,
167167 width : imgSize . width ,
168168 height : imgSize . height ,
169- extname : `.${ imgSize . type || 'png' } ` ,
169+ extname : `.${ imgSize . type ?? 'png' } ` ,
170170 origin : url
171171 }
172172 } catch ( e ) {
0 commit comments