-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
320 lines (285 loc) · 9.6 KB
/
Copy pathbundle.js
File metadata and controls
320 lines (285 loc) · 9.6 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
},{}],2:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
},{}],3:[function(require,module,exports){
const git2json = require('@fabien0102/git2json');
//console.log(git2json);
},{"@fabien0102/git2json":4}],4:[function(require,module,exports){
(function (process){
const parsers = require('./parsers');
// Default fields
// see https://git-scm.com/docs/pretty-formats for placeholder codes
const defaultFields = {
refs: { value: '%d', parser: parsers.refs },
hash: { value: '%H' },
hashAbbrev: { value: '%h' },
tree: { value: '%T' },
treeAbbrev: { value: '%t' },
parents: { value: '%P', parser: parsers.parents },
parentsAbbrev: { value: '%p', parser: parsers.parents },
'author.name': { value: '%an' },
'author.email': { value: '%ae' },
'author.timestamp': { value: '%at', parser: parsers.timestamp },
'committer.name': { value: '%cn' },
'committer.email': { value: '%ce' },
'committer.timestamp': { value: '%ct', parser: parsers.timestamp },
subject: { value: '%s' },
body: { value: '%b' },
notes: { value: '%N' }
};
/**
* Execute git log on current folder and return a pretty object
*
* @param {object} [options]
* @param {object} [options.fields] - fields to exports
* @param {string} [options.path] - path of target git repo
* @return {Promise}
*/
function git2json({ fields = defaultFields, path = process.cwd() } = {}) {
// this require can't be global for mocking issue
const { spawn } = require('child_process');
const keys = Object.keys(fields);
const prettyKeys = keys.map(a => fields[a].value).join('%x00');
const args = ['-C', path, 'log', `--pretty=format:%x01${prettyKeys}%x01`, '--numstat', '--date-order', '--all']
return new Promise((resolve, reject) => {
let stderr = '';
let stdout = '';
const cp = spawn('git', args);
cp.stdout.on('data', data => {
stdout += data;
});
cp.stderr.on('data', data => {
stderr += data;
});
cp.on('error', reject)
.on('close', code => {
if (code !== 0) {
reject(stderr);
}
const data = stdout.split('\u0001');
const stats = data.filter((a, i) => (i + 1) % 2);
let json = data.filter((a, i) => i % 2).map((raw, k) => {
return Object.assign(
raw.split('\u0000').reduce((mem, field, j) => {
const value = fields[keys[j]].parser
? fields[keys[j]].parser(field)
: field.trim();
// Deal with nested key format (eg: 'author.name')
if (/\./.exec(keys[j])) {
let nameParts = keys[j].split('.');
mem[nameParts[0]] = Object.assign({}, mem[nameParts[0]], {
[nameParts[1]]: value
});
} else {
mem[keys[j]] = value;
}
return mem;
}, {}),
{
// Add parsed stats of each commit
stats: stats[k + 1].split('\n').filter(a => a).map(a => {
let b = a.split('\t');
return {
additions: isNaN(b[0]) ? null : +b[0],
deletions: isNaN(b[1]) ? null : +b[1],
file: b[2]
};
})
}
);
});
resolve(json);
});
});
}
module.exports = {
run: git2json,
defaultFields,
parsers
};
}).call(this,require('_process'))
},{"./parsers":5,"_process":2,"child_process":1}],5:[function(require,module,exports){
module.exports = {
/**
* Transform git timestamp to unix timestamp
*/
timestamp: a => +a * 1000,
/**
* Transform parents string to a clean array
*/
parents: a => a.split(' ').filter(b => b),
/**
* Transform refs string to a clean array
*/
refs: a => a.replace(/[\(\)]/g, '')
.replace('->', ',')
.split(', ')
.map(a => a.trim())
.filter(a => a)
};
},{}]},{},[3]);