Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var fs = require('fs'); | ||
var async = require('async'); | ||
|
||
var isGit = function(cb) { | ||
fs.exists(folder+'.git', function(exists) { | ||
if (exists) | ||
return cb('git'); | ||
return cb(null); | ||
}); | ||
} | ||
|
||
var isHg = function(cb) { | ||
fs.exists(folder+'.hg', function(exists) { | ||
if (exists) | ||
return cb('hg'); | ||
return cb(null); | ||
}); | ||
} | ||
|
||
var isSvn = function(cb) { | ||
fs.exists(folder+'.svn', function(exists) { | ||
if (exists) | ||
return cb('svn'); | ||
return cb(null); | ||
}); | ||
} | ||
|
||
module.exports = function identify(folder, cb) { | ||
if (folder[folder.length - 1] !== '/') | ||
folder += '/'; | ||
|
||
async.series([isGit, isHg, isSvn], | ||
function(err, results) { | ||
if (err) | ||
return cb(err); | ||
return cb('No versioning system found'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,22 @@ | ||
var fs = require("fs"); | ||
var parseHg = require('./hg.js'); | ||
var parseGit = require('./git.js'); | ||
var parseSvn = require('./svn.js'); | ||
var identify = require('./identify.js'); | ||
|
||
module.exports.analyze = function analyze(argv, cb) { | ||
module.exports.analyze = function(argv, cb) { | ||
folder = (argv.folder != undefined) ? argv.folder : '.'; | ||
|
||
if (folder[folder.length - 1] !== '/') { | ||
folder = folder + '/'; | ||
} | ||
|
||
fs.exists(folder+'.git', function(exists) { | ||
if (exists) { | ||
return parseGit(folder, cb); | ||
} | ||
fs.exists(folder+'.hg', function(exists) { | ||
if (exists) { | ||
return parseHg(folder, cb); | ||
} | ||
fs.exists(folder+'.svn', function(exists) { | ||
if (exists) { | ||
return parseSvn(folder, cb); | ||
} | ||
else { | ||
return cb({ | ||
msg : 'No versioning system found', | ||
path : folder | ||
}); | ||
} | ||
}); | ||
}); | ||
}); | ||
identify(folder, function(type) { | ||
if (type === 'git') | ||
return parseGit(folder, cb); | ||
else if (type === 'hg') | ||
return parseHg(folder, cb); | ||
else if (type === 'svn') | ||
return parseSvn(folder, cb); | ||
else | ||
return cb({ | ||
msg : type, | ||
path : folder | ||
}); | ||
}); | ||
} |