UNPKG

8.86 kBJavaScriptView Raw
1"use strict";
2
3var cov_242ewvhlu5 = function () {
4 var path = "/home/travis/build/commitizen/cz-cli/src/common/util.js";
5 var hash = "bc7147643a51aded92d9cfa9976b5026f592e01a";
6 var global = new Function("return this")();
7 var gcv = "__coverage__";
8 var coverageData = {
9 path: "/home/travis/build/commitizen/cz-cli/src/common/util.js",
10 statementMap: {
11 "0": {
12 start: {
13 line: 15,
14 column: 2
15 },
16 end: {
17 line: 20,
18 column: 3
19 }
20 },
21 "1": {
22 start: {
23 line: 16,
24 column: 30
25 },
26 end: {
27 line: 16,
28 column: 86
29 }
30 },
31 "2": {
32 start: {
33 line: 17,
34 column: 4
35 },
36 end: {
37 line: 17,
38 column: 43
39 }
40 },
41 "3": {
42 start: {
43 line: 19,
44 column: 4
45 },
46 end: {
47 line: 19,
48 column: 21
49 }
50 },
51 "4": {
52 start: {
53 line: 27,
54 column: 2
55 },
56 end: {
57 line: 27,
58 column: 53
59 }
60 },
61 "5": {
62 start: {
63 line: 34,
64 column: 2
65 },
66 end: {
67 line: 42,
68 column: 3
69 }
70 },
71 "6": {
72 start: {
73 line: 36,
74 column: 4
75 },
76 end: {
77 line: 36,
78 column: 17
79 }
80 },
81 "7": {
82 start: {
83 line: 37,
84 column: 9
85 },
86 end: {
87 line: 42,
88 column: 3
89 }
90 },
91 "8": {
92 start: {
93 line: 38,
94 column: 4
95 },
96 end: {
97 line: 38,
98 column: 17
99 }
100 },
101 "9": {
102 start: {
103 line: 40,
104 column: 18
105 },
106 end: {
107 line: 40,
108 column: 20
109 }
110 },
111 "10": {
112 start: {
113 line: 41,
114 column: 4
115 },
116 end: {
117 line: 41,
118 column: 93
119 }
120 },
121 "11": {
122 start: {
123 line: 46,
124 column: 2
125 },
126 end: {
127 line: 46,
128 column: 41
129 }
130 }
131 },
132 fnMap: {
133 "0": {
134 name: "getParsedJsonFromFile",
135 decl: {
136 start: {
137 line: 14,
138 column: 9
139 },
140 end: {
141 line: 14,
142 column: 30
143 }
144 },
145 loc: {
146 start: {
147 line: 14,
148 column: 71
149 },
150 end: {
151 line: 21,
152 column: 1
153 }
154 },
155 line: 14
156 },
157 "1": {
158 name: "getParsedPackageJsonFromPath",
159 decl: {
160 start: {
161 line: 26,
162 column: 9
163 },
164 end: {
165 line: 26,
166 column: 37
167 }
168 },
169 loc: {
170 start: {
171 line: 26,
172 column: 45
173 },
174 end: {
175 line: 28,
176 column: 1
177 }
178 },
179 line: 26
180 },
181 "2": {
182 name: "isFunction",
183 decl: {
184 start: {
185 line: 33,
186 column: 9
187 },
188 end: {
189 line: 33,
190 column: 19
191 }
192 },
193 loc: {
194 start: {
195 line: 33,
196 column: 38
197 },
198 end: {
199 line: 43,
200 column: 1
201 }
202 },
203 line: 33
204 },
205 "3": {
206 name: "isInTest",
207 decl: {
208 start: {
209 line: 45,
210 column: 9
211 },
212 end: {
213 line: 45,
214 column: 17
215 }
216 },
217 loc: {
218 start: {
219 line: 45,
220 column: 21
221 },
222 end: {
223 line: 47,
224 column: 1
225 }
226 },
227 line: 45
228 }
229 },
230 branchMap: {
231 "0": {
232 loc: {
233 start: {
234 line: 14,
235 column: 52
236 },
237 end: {
238 line: 14,
239 column: 69
240 }
241 },
242 type: "default-arg",
243 locations: [{
244 start: {
245 line: 14,
246 column: 63
247 },
248 end: {
249 line: 14,
250 column: 69
251 }
252 }],
253 line: 14
254 },
255 "1": {
256 loc: {
257 start: {
258 line: 34,
259 column: 2
260 },
261 end: {
262 line: 42,
263 column: 3
264 }
265 },
266 type: "if",
267 locations: [{
268 start: {
269 line: 34,
270 column: 2
271 },
272 end: {
273 line: 42,
274 column: 3
275 }
276 }, {
277 start: {
278 line: 34,
279 column: 2
280 },
281 end: {
282 line: 42,
283 column: 3
284 }
285 }],
286 line: 34
287 },
288 "2": {
289 loc: {
290 start: {
291 line: 37,
292 column: 9
293 },
294 end: {
295 line: 42,
296 column: 3
297 }
298 },
299 type: "if",
300 locations: [{
301 start: {
302 line: 37,
303 column: 9
304 },
305 end: {
306 line: 42,
307 column: 3
308 }
309 }, {
310 start: {
311 line: 37,
312 column: 9
313 },
314 end: {
315 line: 42,
316 column: 3
317 }
318 }],
319 line: 37
320 },
321 "3": {
322 loc: {
323 start: {
324 line: 41,
325 column: 11
326 },
327 end: {
328 line: 41,
329 column: 92
330 }
331 },
332 type: "binary-expr",
333 locations: [{
334 start: {
335 line: 41,
336 column: 11
337 },
338 end: {
339 line: 41,
340 column: 26
341 }
342 }, {
343 start: {
344 line: 41,
345 column: 30
346 },
347 end: {
348 line: 41,
349 column: 92
350 }
351 }],
352 line: 41
353 }
354 },
355 s: {
356 "0": 0,
357 "1": 0,
358 "2": 0,
359 "3": 0,
360 "4": 0,
361 "5": 0,
362 "6": 0,
363 "7": 0,
364 "8": 0,
365 "9": 0,
366 "10": 0,
367 "11": 0
368 },
369 f: {
370 "0": 0,
371 "1": 0,
372 "2": 0,
373 "3": 0
374 },
375 b: {
376 "0": [0],
377 "1": [0, 0],
378 "2": [0, 0],
379 "3": [0, 0]
380 },
381 _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184",
382 hash: "bc7147643a51aded92d9cfa9976b5026f592e01a"
383 };
384 var coverage = global[gcv] || (global[gcv] = {});
385
386 if (coverage[path] && coverage[path].hash === hash) {
387 return coverage[path];
388 }
389
390 return coverage[path] = coverageData;
391}();
392
393Object.defineProperty(exports, "__esModule", {
394 value: true
395});
396exports.getParsedJsonFromFile = getParsedJsonFromFile;
397exports.getParsedPackageJsonFromPath = getParsedPackageJsonFromPath;
398exports.isFunction = isFunction;
399exports.isInTest = isInTest;
400
401var _fs = _interopRequireDefault(require("fs"));
402
403var _path = _interopRequireDefault(require("path"));
404
405function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
406
407/**
408 * Gets the parsed contents of a json file
409 */
410function getParsedJsonFromFile(filePath, fileName, encoding = (cov_242ewvhlu5.b[0][0]++, 'utf8')) {
411 cov_242ewvhlu5.f[0]++;
412 cov_242ewvhlu5.s[0]++;
413
414 try {
415 var packageJsonContents = (cov_242ewvhlu5.s[1]++, _fs.default.readFileSync(_path.default.join(filePath, fileName), encoding));
416 cov_242ewvhlu5.s[2]++;
417 return JSON.parse(packageJsonContents);
418 } catch (e) {
419 cov_242ewvhlu5.s[3]++;
420 console.error(e);
421 }
422}
423/**
424 * A helper method for getting the contents of package.json at a given path
425 */
426
427
428function getParsedPackageJsonFromPath(path) {
429 cov_242ewvhlu5.f[1]++;
430 cov_242ewvhlu5.s[4]++;
431 return getParsedJsonFromFile(path, 'package.json');
432}
433/**
434 * Test if the passed argument is a function
435 */
436
437
438function isFunction(functionToCheck) {
439 cov_242ewvhlu5.f[2]++;
440 cov_242ewvhlu5.s[5]++;
441
442 if (typeof functionToCheck === "undefined") {
443 cov_242ewvhlu5.b[1][0]++;
444 cov_242ewvhlu5.s[6]++;
445 return false;
446 } else {
447 cov_242ewvhlu5.b[1][1]++;
448 cov_242ewvhlu5.s[7]++;
449
450 if (functionToCheck === null) {
451 cov_242ewvhlu5.b[2][0]++;
452 cov_242ewvhlu5.s[8]++;
453 return false;
454 } else {
455 cov_242ewvhlu5.b[2][1]++;
456 var getType = (cov_242ewvhlu5.s[9]++, {});
457 cov_242ewvhlu5.s[10]++;
458 return (cov_242ewvhlu5.b[3][0]++, functionToCheck) && (cov_242ewvhlu5.b[3][1]++, getType.toString.call(functionToCheck) === '[object Function]');
459 }
460 }
461}
462
463function isInTest() {
464 cov_242ewvhlu5.f[3]++;
465 cov_242ewvhlu5.s[11]++;
466 return typeof global.it === 'function';
467}
\No newline at end of file