-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
85 lines (70 loc) · 1.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// bepo.js
/*eslint-disable consistent-this */
var series = require('array-series')
var gits = require('quick-gits')
// Pass in the settings to get a new Repo object
function repo (obj) {
var git = gits(obj.worktree)
var self = git
// Its this or mucking with superclass
var gitClone = self.clone
function clone (cb) {
if (obj.remote) {
gitClone.bind(self, obj.remote)(cb)
} else {
cb(new Error('No remote specified'))
}
}
self.clone = clone
function pull (cb) {
git(['pull'], {
timeout: 15000
}, cb)
}
self.pull = pull
function config (options, cb) {
var configStr = ['config'].concat(options || [])
git(configStr, cb)
}
self.config = config
function setUser (cb) {
config(['user.name', obj.name || 'bepo user'], cb)
}
self.setUser = setUser
function setEmail (cb) {
config(['user.email', obj.email], cb)
}
self.setEmail = setEmail
function configure (cb) {
series([
setUser,
setEmail
], cb)
}
self.configure = configure
function add (files, cb) {
var addFiles = ['add'].concat(files || ['-A'])
git(addFiles, cb)
}
self.add = add
function commit (msg, cb) {
git(['commit', '-m', msg], cb)
}
self.commit = commit
function push (cb) {
git(['push', 'origin', 'master'], cb)
}
self.push = push
function publish (cb) {
series([
pull,
add.bind(self, ['-A']),
commit.bind(self, "'bebo made a commit'"),
push
], cb)
}
self.publish = publish
return self
}
module.exports = repo
/*eslint-enable consistent-this */