1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
8 |
|
9 | var _lodash = require('lodash');
|
10 |
|
11 | var _lodash2 = _interopRequireDefault(_lodash);
|
12 |
|
13 | var _actions = require('./actions');
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16 |
|
17 | var initState = {
|
18 | log: []
|
19 | };
|
20 |
|
21 | function reducer() {
|
22 | var state = arguments.length <= 0 || arguments[0] === undefined ? initState : arguments[0];
|
23 | var action = arguments[1];
|
24 |
|
25 | var newLog;
|
26 | switch (action.type) {
|
27 | case _actions.INIT_PROCESS:
|
28 | newLog = _lodash2.default.clone(state.log);
|
29 | newLog[action.payload.id] = { action: action.payload.argv, output: [] };
|
30 | return _extends({}, state, {
|
31 | log: newLog
|
32 | });
|
33 | case _actions.LOG_PROCESS:
|
34 | newLog = _lodash2.default.clone(state.log);
|
35 | var processId = action.payload.id;
|
36 | var process = newLog[processId] || { output: [] };
|
37 | process.output.push(action.payload.output);
|
38 | return _extends({}, state, {
|
39 | log: newLog
|
40 | });
|
41 | }
|
42 | return state;
|
43 | }
|
44 |
|
45 | exports.default = reducer; |
\ | No newline at end of file |