Skip to content

Commit 216daaa

Browse files
committed
added check for svn being avaialbe in $PATH
1 parent fe7aa3e commit 216daaa

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/extension.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ const SvnCommands = require("./commands");
66
const Model = require("./model");
77

88
function activate(context) {
9-
console.log("svn-scm is now active!");
10-
119
const disposable = [];
1210
const svn = new Svn();
1311
const model = new Model(svn);
1412
const contentProvider = new svnContentProvider();
1513
const commands = new SvnCommands(model);
1614

15+
console.log("svn-scm is now active!");
16+
1717
context.subscriptions.push(disposable);
1818
}
1919
exports.activate = activate;

src/svn.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
const SvnSpawn = require("svn-spawn");
22
const vscode = require("vscode");
3+
const cp = require("child_process");
34

45
function svn(cwd = null) {
56
this.client = new SvnSpawn({
67
noAuthCache: true,
78
cwd: cwd
89
});
10+
11+
this.isSVNAvailable()
12+
.then(() => {})
13+
.catch(() => {
14+
vscode.window.showErrorMessage(
15+
"SVN is not avaialbe in your $PATH. svn-scm is unable to run!"
16+
);
17+
});
918
}
1019

1120
svn.prototype.getRepositoryRoot = async function(path) {
@@ -21,6 +30,19 @@ svn.prototype.getRepositoryRoot = async function(path) {
2130
}
2231
};
2332

33+
svn.prototype.isSVNAvailable = async function() {
34+
return new Promise((resolve, reject) => {
35+
const result = cp.exec("svn --version");
36+
37+
result.stdout.on("data", data => {
38+
resolve();
39+
});
40+
result.stderr.on("data", data => {
41+
reject();
42+
});
43+
});
44+
};
45+
2446
svn.prototype.open = function(repositoryRoot) {
2547
return new Repository(this, repositoryRoot);
2648
};

0 commit comments

Comments
 (0)