Skip to content

Commit 962aa4f

Browse files
committed
fixed svn check
1 parent 1762e4c commit 962aa4f

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/model.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ export class Model {
2929
const config = workspace.getConfiguration("svn");
3030
this.enabled = config.get("enabled") === true;
3131

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(() => {});
3742
}
3843

3944
private init(): void {

src/svn.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ interface CpOptions {
99
}
1010

1111
export class Svn {
12-
constructor() {
13-
this.isSvnAvailable();
14-
}
15-
1612
async exec(cwd: string, args: any[], options: CpOptions = {}) {
1713
if (cwd) {
1814
options.cwd = cwd;
@@ -61,15 +57,17 @@ export class Svn {
6157
}
6258
}
6359

64-
private isSvnAvailable() {
60+
public async isSvnAvailable() {
6561
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);
7166
reject();
72-
});
67+
}
68+
69+
resolve();
70+
});
7371
});
7472
}
7573

0 commit comments

Comments
 (0)