@@ -55,8 +55,8 @@ export default class SPAClient {
55
55
"Authorization" : `Bearer ${ config . authToken } `
56
56
}
57
57
} )
58
- this . http . interceptors . response . use ( ( resp ) => resp , ( error ) => {
59
- return Promise . reject ( error . cause )
58
+ this . http . interceptors . response . use ( ( resp ) => resp , ( error ) => {
59
+ return Promise . reject ( error . cause )
60
60
} )
61
61
}
62
62
@@ -117,6 +117,10 @@ export default class SPAClient {
117
117
if ( ! ( fs . existsSync ( absolutePath ) && fs . statSync ( absolutePath ) . isDirectory ( ) ) ) {
118
118
throw `path:${ path } is not directory or does not exists`
119
119
}
120
+ const files = await walkdir . async ( absolutePath , { return_object : true } )
121
+ if ( Object . keys ( files ) . length == 0 ) {
122
+ throw `path:${ path } has no files`
123
+ }
120
124
let realVersion : number ;
121
125
if ( ! version ) {
122
126
const positionResp = await this . getUploadPosition ( domain )
@@ -136,7 +140,6 @@ export default class SPAClient {
136
140
result [ item . path ] = item
137
141
return result
138
142
} , { } as { [ key : string ] : ShortMetaData } )
139
- const files = await walkdir . async ( absolutePath , { return_object : true } )
140
143
const uploadingFiles = Object . keys ( files ) . reduce ( ( result , filePath ) => {
141
144
const fileStat = files [ filePath ]
142
145
if ( fileStat . isFile ( ) ) {
@@ -151,7 +154,9 @@ export default class SPAClient {
151
154
152
155
} , [ ] as { key : string , filePath : string } [ ] )
153
156
if ( ! uploadingFiles . length ) {
154
- throw "There is no file to uploading"
157
+ console . log ( chalk . green ( "all files already upload" ) )
158
+ await this . changeUploadingStatus ( domain , realVersion , UploadingStatus . Finish )
159
+ return
155
160
}
156
161
console . log ( chalk . green ( `there are ${ uploadingFiles . length } files to upload` ) )
157
162
await this . changeUploadingStatus ( domain , realVersion , UploadingStatus . Uploading )
0 commit comments