forked from nodester/nodester
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
Contra
committed
Sep 14, 2011
1 parent
ab56071
commit 3094692
Showing
1 changed file
with
21 additions
and
21 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 |
---|---|---|
@@ -1,42 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
require('colors'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var config = require('../config').opt; | ||
var hosted = path.join(config.home_dir, config.hosted_apps_subdir); | ||
var exists = path.existsSync; | ||
var util = require('util'); | ||
process.chdir(hosted); | ||
require('colors'); | ||
|
||
util.print('Reading git repos:'.magenta); | ||
var src = path.join(config.app_dir, 'scripts', 'gitrepoclone.sh'); | ||
var copy = function() { | ||
var copy = function () { | ||
if (repos.length) { | ||
var dest = repos.pop(); | ||
var is = fs.createReadStream(src); | ||
var os = fs.createWriteStream(dest); | ||
util.pump(is, os, copy); | ||
var dest = repos.pop(); | ||
var is = fs.createReadStream(src); | ||
var os = fs.createWriteStream(dest); | ||
util.pump(is, os, copy); | ||
} else { | ||
util.print(' [done]\n'.white); | ||
util.print(' [done]\n'.white); | ||
} | ||
}; | ||
}; | ||
|
||
var repos = []; | ||
var repos = []; | ||
var dirs = fs.readdirSync('.'); | ||
dirs.forEach(function(v) { | ||
if (exists(v)) { | ||
dirs.forEach(function (v) { | ||
if (exists(v)) { | ||
var stat = fs.statSync(v); | ||
if (stat.isDirectory()) { | ||
var dirs = fs.readdirSync(v); | ||
dirs.forEach(function(i) { | ||
if (path.extname(i) === '.git') { | ||
repos.push(path.join(hosted, v, i, 'hooks', 'post-receive')); | ||
} | ||
}); | ||
if (stat.isDirectory()) { | ||
var dirs = fs.readdirSync(v); | ||
dirs.forEach(function (i) { | ||
if (path.extname(i) === '.git') { | ||
repos.push(path.join(hosted, v, i, 'hooks', 'post-receive')); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
util.print((' (' + repos.length + ')').yellow + ' [done]\n'.white); | ||
util.print('Processing git commit hooks'.magenta); | ||
copy(); | ||
|
||
copy(); |