UNPKG

1.57 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.programReducer = void 0;
5var _reporter = require("gatsby-cli/lib/reporter/reporter");
6const initialState = {
7 directory: `/`,
8 status: `BOOTSTRAPPING`,
9 _: `develop`,
10 useYarn: false,
11 open: false,
12 openTracingConfigFile: ``,
13 port: 80,
14 proxyPort: 80,
15 host: `localhost`,
16 sitePackageJson: {},
17 extensions: [],
18 browserslist: [],
19 report: _reporter.reporter,
20 disablePlugins: []
21};
22const programReducer = (state = initialState, action) => {
23 switch (action.type) {
24 case `SET_PROGRAM`:
25 return {
26 ...state,
27 ...action.payload
28 };
29 case `SET_PROGRAM_EXTENSIONS`:
30 return {
31 ...state,
32 extensions: action.payload
33 };
34 case `SET_PROGRAM_STATUS`:
35 return {
36 ...state,
37 status: `BOOTSTRAP_FINISHED`
38 };
39 case `DISABLE_PLUGINS_BY_NAME`:
40 {
41 if (!state.disablePlugins) {
42 state.disablePlugins = [];
43 }
44 for (const pluginToDisable of action.payload.pluginsToDisable) {
45 let disabledPlugin = state.disablePlugins.find(entry => entry.name === pluginToDisable);
46 if (!disabledPlugin) {
47 disabledPlugin = {
48 name: pluginToDisable,
49 reasons: []
50 };
51 state.disablePlugins.push(disabledPlugin);
52 }
53 disabledPlugin.reasons.push(action.payload.reason);
54 }
55 return state;
56 }
57 default:
58 return state;
59 }
60};
61exports.programReducer = programReducer;
62//# sourceMappingURL=program.js.map
\No newline at end of file