Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make missing directories in create()

  • Loading branch information...
commit 5ba48639420a1c2c13dc5cf1807a3b096edc20de 1 parent 31b77eb
@substack authored
Showing with 27 additions and 14 deletions.
  1. +26 −13 index.js
  2. +1 −1  package.json
View
39 index.js
@@ -34,22 +34,35 @@ Git.prototype.mkdir = function (dir, cb) {
};
Git.prototype.create = function (repo, cb) {
+ var self = this;
+ if (typeof cb !== 'function') cb = function () {};
var cwd = process.cwd();
- var dir = path.join(this.repoDir, repo);
- if (this.checkout) {
- var ps = spawn('git', [ 'init', dir ]);
- } else {
- var ps = spawn('git', [ 'init', '--bare', dir ]);
- }
-
- var err = '';
- ps.stderr.on('data', function (buf) { err += buf });
+ if (/\.\.|^\//.test(repo)) return cb('invalid repo name');
- onexit(ps, function (code) {
- if (!cb) {}
- else if (code) cb(err || true)
- else cb(null)
+ self.exists(repo, function (ex) {
+ if (!ex) self.mkdir(repo, next)
+ else next()
});
+
+ function next (err) {
+ if (err) return cb(err);
+
+ var dir = path.join(self.repoDir, repo);
+ if (self.checkout) {
+ var ps = spawn('git', [ 'init', dir ]);
+ } else {
+ var ps = spawn('git', [ 'init', '--bare', dir ]);
+ }
+
+ var err = '';
+ ps.stderr.on('data', function (buf) { err += buf });
+
+ onexit(ps, function (code) {
+ if (!cb) {}
+ else if (code) cb(err || true)
+ else cb(null)
+ });
+ }
};
Git.prototype.handle = require('./lib/handle');
View
2  package.json
@@ -1,7 +1,7 @@
{
"name" : "pushover",
"description" : "git push deploy server over http",
- "version" : "1.0.1",
+ "version" : "1.0.2",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/pushover.git"
Please sign in to comment.
Something went wrong with that request. Please try again.