projects
Version:
You're a prolific developer (or you want to be). Manage, keep track of, and show off your projects.
53 lines (38 loc) • 1.11 kB
JavaScript
// description: find git repositories
var fs = require('fs');
var Glob = require('glob').Glob;
var path = require('path');
var storage = require('../lib/storage.js');
var utilities = require('../lib/utilities.js');
var program = utilities.programDefaults('find-repos', '<command>');
program.parse(process.argv);
storage.setup(function () {
var glob = new Glob('/**/.git', {silent: true});
glob.on('match', function (match) {
fs.stat(match, function (err, stats) {
var parent = utilities.contract(path.resolve(match, '..'));
// Sometimes there are broken symlinks
if (err && err.code === 'ENOENT') {
return console.log(parent);
} else if (err) {
throw err;
}
if (stats.isDirectory()) {
console.log(parent);
}
});
});
glob.on('error', function (err) {
if (err.code === 'EACCES' ||
err.code === 'EBADF') {
return;
}
console.log('Error globbing projects:', err);
process.exit(1);
});
glob.on('end', function () {
console.log('Done');
});
});
;