Skip to content

Commit 8748df2

Browse files
committed
added repository object
1 parent 299bbbb commit 8748df2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/repository.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const Svn = require('./svn');
2+
3+
function repository() {
4+
this.svn = new Svn();
5+
this.filePaths = [];
6+
this.update();
7+
}
8+
9+
repository.prototype.update = function() {
10+
this.svn.getStatus().then(result => {
11+
result.forEach(item => {
12+
this.filePaths.push(item.$.path);
13+
});
14+
});
15+
}
16+
17+
repository.prototype.getRepositoryFilePath = function(relativePath) {
18+
let repositoryFilePath = false;
19+
20+
this.filePaths.forEach(filePath => {
21+
const fileName = relativePath.split('/').pop();
22+
23+
let regex = new RegExp(fileName, 'g');
24+
let matches = filePath.match(regex);
25+
26+
if (matches) {
27+
repositoryFilePath = filePath;
28+
}
29+
});
30+
31+
return repositoryFilePath;
32+
}
33+
34+
module.exports = repository;

0 commit comments

Comments
 (0)