1
+ const { reportPluginLoadError } = require ( '../core/status' )
2
+
1
3
const { callChild } = require ( './ipc' )
2
4
3
5
// Retrieve all plugins commands
4
6
// Can use either a module name or a file path to the plugin.
5
- const loadPlugins = async function ( { pluginsOptions, childProcesses, netlifyConfig, utilsData, token, constants } ) {
7
+ const loadPlugins = async function ( {
8
+ pluginsOptions,
9
+ childProcesses,
10
+ netlifyConfig,
11
+ utilsData,
12
+ token,
13
+ constants,
14
+ mode,
15
+ api,
16
+ } ) {
6
17
const pluginsCommands = await Promise . all (
7
18
pluginsOptions . map ( ( pluginOptions , index ) =>
8
19
loadPlugin ( pluginOptions , {
@@ -12,6 +23,8 @@ const loadPlugins = async function({ pluginsOptions, childProcesses, netlifyConf
12
23
utilsData,
13
24
token,
14
25
constants,
26
+ mode,
27
+ api,
15
28
} ) ,
16
29
) ,
17
30
)
@@ -22,26 +35,32 @@ const loadPlugins = async function({ pluginsOptions, childProcesses, netlifyConf
22
35
// Retrieve plugin commands for one plugin.
23
36
// Do it by executing the plugin `load` event handler.
24
37
const loadPlugin = async function (
25
- { package, packageJson, pluginPath, manifest, inputs, local, core } ,
26
- { childProcesses, index, netlifyConfig, utilsData, token, constants } ,
38
+ { package, packageJson, packageJson : { version } = { } , pluginPath, manifest, inputs, local, core } ,
39
+ { childProcesses, index, netlifyConfig, utilsData, token, constants, mode , api } ,
27
40
) {
28
41
const { childProcess } = childProcesses [ index ]
42
+ const event = 'load'
29
43
30
- const { pluginCommands } = await callChild (
31
- childProcess ,
32
- 'load' ,
33
- { pluginPath, manifest, inputs, netlifyConfig, utilsData, token, constants } ,
34
- { plugin : { package, packageJson } , location : { event : 'load' , package, local } } ,
35
- )
36
- const pluginCommandsA = pluginCommands . map ( ( { event } ) => ( {
37
- event,
38
- package,
39
- local,
40
- core,
41
- packageJson,
42
- childProcess,
43
- } ) )
44
- return pluginCommandsA
44
+ try {
45
+ const { pluginCommands } = await callChild (
46
+ childProcess ,
47
+ 'load' ,
48
+ { pluginPath, manifest, inputs, netlifyConfig, utilsData, token, constants } ,
49
+ { plugin : { package, packageJson } , location : { event, package, local } } ,
50
+ )
51
+ const pluginCommandsA = pluginCommands . map ( ( { event } ) => ( {
52
+ event,
53
+ package,
54
+ local,
55
+ core,
56
+ packageJson,
57
+ childProcess,
58
+ } ) )
59
+ return pluginCommandsA
60
+ } catch ( error ) {
61
+ await reportPluginLoadError ( { error, api, mode, event, package, version } )
62
+ throw error
63
+ }
45
64
}
46
65
47
66
module . exports = { loadPlugins }
0 commit comments