1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _regenerator = require("babel-runtime/regenerator");
|
8 |
|
9 | var _regenerator2 = _interopRequireDefault(_regenerator);
|
10 |
|
11 | var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
|
12 |
|
13 | var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16 |
|
17 | exports.default = function () {
|
18 | var _ref = (0, _asyncToGenerator3.default)( _regenerator2.default.mark(function _callee(percyClient, build, story, widths, minimumHeight, assets, storyHtml) {
|
19 | var resource, snapshotOptions, snapshot, missingResources;
|
20 | return _regenerator2.default.wrap(function _callee$(_context) {
|
21 | while (1) {
|
22 | switch (_context.prev = _context.next) {
|
23 | case 0:
|
24 | _context.prev = 0;
|
25 | resource = percyClient.makeRootResource(story.name, storyHtml, story.encodedParams);
|
26 |
|
27 |
|
28 | if (story.options) {
|
29 | widths = story.options.widths || widths;
|
30 | }
|
31 |
|
32 | snapshotOptions = {
|
33 | name: story.name,
|
34 | widths: widths,
|
35 | minimumHeight: minimumHeight,
|
36 | enableJavaScript: true
|
37 | };
|
38 | _context.next = 6;
|
39 | return percyClient.createSnapshot(build, [resource], snapshotOptions);
|
40 |
|
41 | case 6:
|
42 | snapshot = _context.sent;
|
43 | missingResources = percyClient.getMissingResourceShas(snapshot);
|
44 |
|
45 | if (!(missingResources.length > 0)) {
|
46 | _context.next = 11;
|
47 | break;
|
48 | }
|
49 |
|
50 | _context.next = 11;
|
51 | return percyClient.uploadResources(build, [resource]);
|
52 |
|
53 | case 11:
|
54 | _context.next = 13;
|
55 | return percyClient.finalizeSnapshot(snapshot, story.name);
|
56 |
|
57 | case 13:
|
58 | _context.next = 19;
|
59 | break;
|
60 |
|
61 | case 15:
|
62 | _context.prev = 15;
|
63 | _context.t0 = _context["catch"](0);
|
64 |
|
65 | _context.t0._percy = {
|
66 | story: story
|
67 | };
|
68 | throw _context.t0;
|
69 |
|
70 | case 19:
|
71 | case "end":
|
72 | return _context.stop();
|
73 | }
|
74 | }
|
75 | }, _callee, this, [[0, 15]]);
|
76 | }));
|
77 |
|
78 | function uploadStory(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
79 | return _ref.apply(this, arguments);
|
80 | }
|
81 |
|
82 | return uploadStory;
|
83 | }(); |
\ | No newline at end of file |