1 |
|
2 |
|
3 | var arr = [];
|
4 | var each = arr.forEach;
|
5 | var slice = arr.slice;
|
6 |
|
7 | module.exports.extend = function(obj) {
|
8 | each.call(slice.call(arguments, 1), function(source) {
|
9 | if (source) {
|
10 | for (var prop in source) {
|
11 | obj[prop] = source[prop];
|
12 | }
|
13 | }
|
14 | });
|
15 | return obj;
|
16 | };
|
17 |
|
18 | module.exports.processArgs = function(opts, callback, defaultOpts) {
|
19 | if (!callback && typeof opts === 'function') {
|
20 | callback = opts;
|
21 | opts = null;
|
22 | }
|
23 | return {
|
24 | callback: callback,
|
25 | opts: module.exports.extend({}, defaultOpts, opts)
|
26 | };
|
27 | };
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | module.exports.parseRepositoryTag = function(input) {
|
41 | var separatorPos;
|
42 | var digestPos = input.indexOf('@');
|
43 | var colonPos = input.lastIndexOf(':');
|
44 |
|
45 | if (digestPos >= 0) {
|
46 | separatorPos = digestPos;
|
47 | } else if (colonPos >= 0) {
|
48 | separatorPos = colonPos;
|
49 | } else {
|
50 |
|
51 | return {
|
52 | repository: input
|
53 | };
|
54 | }
|
55 |
|
56 |
|
57 | var tag = input.slice(separatorPos + 1);
|
58 |
|
59 |
|
60 | if (tag.indexOf('/') === -1) {
|
61 | return {
|
62 | repository: input.slice(0, separatorPos),
|
63 | tag: tag
|
64 | };
|
65 | }
|
66 |
|
67 | return {
|
68 | repository: input
|
69 | };
|
70 | };
|