1
- import * as fs from "original-fs" ;
2
1
import * as path from "path" ;
3
2
import {
4
3
commands ,
@@ -16,6 +15,7 @@ import {
16
15
WorkspaceEdit
17
16
} from "vscode" ;
18
17
import { ICommandOptions , Status , SvnUriAction } from "../common/types" ;
18
+ import { exists , readFile , stat , unlink } from "../fs" ;
19
19
import { inputIgnoreList } from "../ignoreitems" ;
20
20
import { applyLineChanges } from "../lineChanges" ;
21
21
import { Model } from "../model" ;
@@ -194,7 +194,7 @@ export abstract class Command implements Disposable {
194
194
preserveFocus ?: boolean ,
195
195
preserveSelection ?: boolean
196
196
) : Promise < void > {
197
- let left = this . getLeftResource ( resource , against ) ;
197
+ let left = await this . getLeftResource ( resource , against ) ;
198
198
let right = this . getRightResource ( resource , against ) ;
199
199
const title = this . getTitle ( resource , against ) ;
200
200
@@ -209,8 +209,8 @@ export abstract class Command implements Disposable {
209
209
}
210
210
211
211
if (
212
- fs . existsSync ( right . fsPath ) &&
213
- fs . statSync ( right . fsPath ) . isDirectory ( )
212
+ ( await exists ( right . fsPath ) ) &&
213
+ ( await stat ( right . fsPath ) ) . isDirectory ( )
214
214
) {
215
215
return ;
216
216
}
@@ -244,10 +244,10 @@ export abstract class Command implements Disposable {
244
244
) ;
245
245
}
246
246
247
- protected getLeftResource (
247
+ protected async getLeftResource (
248
248
resource : Resource ,
249
249
against : string = ""
250
- ) : Uri | undefined {
250
+ ) : Promise < Uri | undefined > {
251
251
if ( resource . remote ) {
252
252
if ( resource . type !== Status . DELETED ) {
253
253
return toSvnUri ( resource . resourceUri , SvnUriAction . SHOW , {
@@ -266,11 +266,11 @@ export abstract class Command implements Disposable {
266
266
// Show file if has conflicts marks
267
267
if (
268
268
resource . type === Status . CONFLICTED &&
269
- fs . existsSync ( resource . resourceUri . fsPath )
269
+ ( await exists ( resource . resourceUri . fsPath ) )
270
270
) {
271
- const text = fs . readFileSync ( resource . resourceUri . fsPath , {
271
+ const text = ( await readFile ( resource . resourceUri . fsPath , {
272
272
encoding : "utf8"
273
- } ) ;
273
+ } ) ) as string ;
274
274
275
275
// Check for lines begin with "<<<<<<", "=======", ">>>>>>>"
276
276
if ( / ^ < { 7 } [ ^ ] + ^ = { 7 } [ ^ ] + ^ > { 7 } / m. test ( text ) ) {
@@ -394,8 +394,12 @@ export abstract class Command implements Disposable {
394
394
try {
395
395
const tempFile = path . join ( repository . root , ".svn" , "tmp" , "svn.patch" ) ;
396
396
397
- if ( fs . existsSync ( tempFile ) ) {
398
- fs . unlinkSync ( tempFile ) ;
397
+ if ( await exists ( tempFile ) ) {
398
+ try {
399
+ await unlink ( tempFile ) ;
400
+ } catch ( err ) {
401
+ // TODO(cjohnston)//log error
402
+ }
399
403
}
400
404
401
405
const uri = Uri . file ( tempFile ) . with ( {
0 commit comments