执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
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
 
 
 
var FileStatusSummary = require('./FileStatusSummary');
 
module.exports = StatusSummary;
 
/**
 * The StatusSummary is returned as a response to getting `git().status()`
 *
 * @constructor
 */
function StatusSummary () {
   this.not_added = [];
   this.conflicted = [];
   this.created = [];
   this.deleted = [];
   this.modified = [];
   this.renamed = [];
   this.files = [];
   this.staged = [];
}
 
 
/**
 * Number of commits ahead of the tracked branch
 * @type {number}
 */
StatusSummary.prototype.ahead = 0;
 
/**
 * Number of commits behind the tracked branch
 * @type {number}
 */
StatusSummary.prototype.behind = 0;
 
/**
 * Name of the current branch
 * @type {null}
 */
StatusSummary.prototype.current = null;
 
/**
 * Name of the branch being tracked
 * @type {string}
 */
StatusSummary.prototype.tracking = null;
 
/**
 * All files represented as an array of objects containing the `path` and status in `index` and
 * in the `working_dir`.
 *
 * @type {Array}
 */
StatusSummary.prototype.files = null;
 
/**
 * Gets whether this StatusSummary represents a clean working branch.
 *
 * @return {boolean}
 */
StatusSummary.prototype.isClean = function () {
   return 0 === Object.keys(this).filter(function (name) {
      return Array.isArray(this[name]) && this[name].length;
   }, this).length;
};
 
StatusSummary.parsers = {
   '##': function (line, status) {
      var aheadReg = /ahead (\d+)/;
      var behindReg = /behind (\d+)/;
      var currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
      var trackingReg = /\.{3}(\S*)/;
      var regexResult;
 
      regexResult = aheadReg.exec(line);
      status.ahead = regexResult && +regexResult[1] || 0;
 
      regexResult = behindReg.exec(line);
      status.behind = regexResult && +regexResult[1] || 0;
 
      regexResult = currentReg.exec(line);
      status.current = regexResult && regexResult[1];
 
      regexResult = trackingReg.exec(line);
      status.tracking = regexResult && regexResult[1];
   },
 
   '??': function (line, status) {
      status.not_added.push(line);
   },
 
   A: function (line, status) {
      status.created.push(line);
   },
 
   AM: function (line, status) {
      status.created.push(line);
   },
 
   D: function (line, status) {
      status.deleted.push(line);
   },
 
   M: function (line, status, indexState) {
      status.modified.push(line);
 
      if (indexState === 'M') {
         status.staged.push(line);
      }
   },
 
   R: function (line, status) {
      var detail = /^(.+) -> (.+)$/.exec(line) || [null, line, line];
 
      status.renamed.push({
         from: detail[1],
         to: detail[2]
      });
   },
 
   UU: function (line, status) {
      status.conflicted.push(line);
   }
};
 
StatusSummary.parsers.MM = StatusSummary.parsers.M;
 
/* Map all unmerged status code combinations to UU to mark as conflicted */
StatusSummary.parsers.AA = StatusSummary.parsers.UU;
StatusSummary.parsers.UD = StatusSummary.parsers.UU;
StatusSummary.parsers.DU = StatusSummary.parsers.UU;
StatusSummary.parsers.DD = StatusSummary.parsers.UU;
StatusSummary.parsers.AU = StatusSummary.parsers.UU;
StatusSummary.parsers.UA = StatusSummary.parsers.UU;
 
StatusSummary.parse = function (text) {
   var file;
   var lines = text.trim().split('\n');
   var status = new StatusSummary();
 
   for (var i = 0, l = lines.length; i < l; i++) {
      file = splitLine(lines[i]);
 
      if (!file) {
         continue;
      }
 
      if (file.handler) {
         file.handler(file.path, status, file.index, file.workingDir);
      }
 
      if (file.code !== '##') {
         status.files.push(new FileStatusSummary(file.path, file.index, file.workingDir));
      }
   }
 
   return status;
};
 
 
function splitLine (lineStr) {
   var line = lineStr.trim().match(/(..?)(\s+)(.*)/);
   if (!line || !line[1].trim()) {
      line = lineStr.trim().match(/(..?)\s+(.*)/);
   }
 
   if (!line) {
      return;
   }
 
   var code = line[1];
   if (line[2].length > 1) {
      code += ' ';
   }
   if (code.length === 1 && line[2].length === 1) {
      code = ' ' + code;
   }
 
   return {
      raw: code,
      code: code.trim(),
      index: code.charAt(0),
      workingDir: code.charAt(1),
      handler: StatusSummary.parsers[code.trim()],
      path: line[3]
   };
}