@@ -125,10 +125,13 @@ async function deleteFile(remotePath) {
125
125
}
126
126
127
127
conn . sftp ( ( err , sftp ) => {
128
- sftp
129
- . deleteFile ( remotePath )
130
- . then ( ( res ) => resolve ( ) )
131
- . catch ( ( err ) => console . log ( err ) && resolve ( ) ) ;
128
+ sftp . unlink ( remotePath , ( err ) => {
129
+ if ( err ) {
130
+ return reject ( err ) ;
131
+ }
132
+
133
+ resolve ( ) ;
134
+ } ) ;
132
135
} ) ;
133
136
} ) ;
134
137
}
@@ -183,7 +186,7 @@ watcher.on("add", async (path, stats) => {
183
186
try {
184
187
await uploadFile (
185
188
path ,
186
- p . posix . join ( config . deployDirectory , path . replace ( p . sep , p . posix . sep ) )
189
+ p . posix . join ( config . deployDirectory , path . replaceAll ( p . sep , p . posix . sep ) )
187
190
) ;
188
191
} catch ( err ) {
189
192
console . error ( " ✘" , err ) ;
@@ -195,18 +198,18 @@ watcher.on("change", async (path, stats) => {
195
198
try {
196
199
await uploadFile (
197
200
path ,
198
- p . posix . join ( config . deployDirectory , path . replace ( p . sep , p . posix . sep ) )
201
+ p . posix . join ( config . deployDirectory , path . replaceAll ( p . sep , p . posix . sep ) )
199
202
) ;
200
203
} catch ( err ) {
201
204
console . error ( " ✘" , err ) ;
202
205
}
203
206
} ) ;
204
207
205
208
watcher . on ( "unlink" , async ( path , stats ) => {
206
- process . stdout . write ( `${ Date . now ( ) . toLocaleString ( ) } [-] ${ path } ` ) ;
209
+ process . stdout . write ( `${ new Date ( ) . toLocaleString ( ) } [-] ${ path } ` ) ;
207
210
try {
208
211
await deleteFile (
209
- p . posix . join ( config . deployDirectory , path . replace ( p . sep , p . posix . sep ) )
212
+ p . posix . join ( config . deployDirectory , path . replaceAll ( p . sep , p . posix . sep ) )
210
213
) ;
211
214
} catch ( err ) {
212
215
console . error ( " ✘" , err ) ;
0 commit comments