File tree Expand file tree Collapse file tree 2 files changed +19
-16
lines changed Expand file tree Collapse file tree 2 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,16 @@ export class Model {
29
29
const config = workspace . getConfiguration ( "svn" ) ;
30
30
this . enabled = config . get ( "enabled" ) === true ;
31
31
32
- if ( this . enabled ) {
33
- this . init ( ) ;
34
- } else {
35
- this . disable ( ) ;
36
- }
32
+ svn
33
+ . isSvnAvailable ( )
34
+ . then ( ( ) => {
35
+ if ( this . enabled && svn . isSvnAvailable ( ) ) {
36
+ this . init ( ) ;
37
+ } else {
38
+ this . disable ( ) ;
39
+ }
40
+ } )
41
+ . catch ( ( ) => { } ) ;
37
42
}
38
43
39
44
private init ( ) : void {
Original file line number Diff line number Diff line change @@ -9,10 +9,6 @@ interface CpOptions {
9
9
}
10
10
11
11
export class Svn {
12
- constructor ( ) {
13
- this . isSvnAvailable ( ) ;
14
- }
15
-
16
12
async exec ( cwd : string , args : any [ ] , options : CpOptions = { } ) {
17
13
if ( cwd ) {
18
14
options . cwd = cwd ;
@@ -61,15 +57,17 @@ export class Svn {
61
57
}
62
58
}
63
59
64
- private isSvnAvailable ( ) {
60
+ public async isSvnAvailable ( ) {
65
61
return new Promise ( ( resolve , reject ) => {
66
- this . exec ( "" , [ "--version" ] )
67
- . then ( result => {
68
- resolve ( ) ;
69
- } )
70
- . catch ( result => {
62
+ cp . exec ( "svn --version" , ( error , stdout , stderr ) => {
63
+ if ( error ) {
64
+ console . log ( stderr ) ;
65
+ window . showErrorMessage ( stderr ) ;
71
66
reject ( ) ;
72
- } ) ;
67
+ }
68
+
69
+ resolve ( ) ;
70
+ } ) ;
73
71
} ) ;
74
72
}
75
73
You can’t perform that action at this time.
0 commit comments