-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
52 lines (52 loc) · 1.77 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module.exports = function runPlugin(inputs) {
if (!inputs.triggerAll) {
return {
onPreBuild: () => {
console.log(`triggerAll set to ${inputs.triggerAll}, no fun 🤷🏻♀️!`);
},
};
} else {
return {
onPreBuild: ({ inputs: { keyword } }) => {
console.log('onPreBuild: I run_before_ build commands are executed 🌤');
console.log('I will only use the keyword input: ', keyword);
},
onBuild: ({ inputs }) => {
console.log(
'onBuild: I run while build commands are being executed ⚙️'
);
console.log(`I also know your keyword is: ${inputs.keyword}.`);
console.log(`Oh, and your database URL is: ${inputs.databaseUrl}.`);
},
onPostBuild: ({ constants }) => {
console.log(
'onPostBuild: I run _after_ build commands are executed ✅'
);
console.log('Here are some other things I know thanks to constants:');
console.log(constants);
},
onSuccess: ({ utils }) => {
console.log('onSuccess: I run on build success 🎉');
/*
// Uncomment this block to see the onError code run.
// This is also a good way to handle errors 👇
try {
throw new Error('This is the error 🚨');
} catch (error) {
utils.build.failBuild('Error found, build will fail!', { error });
// utils.build.failPlugin('This fails the plugin but not the build.');
// utils.build.cancelBuild(`This will cancel the build ${error}.`);
}
*/
},
onError: () => {
console.log('onError: I run on build error 🚒');
},
onEnd: () => {
console.log(
'onEnd: I run on build error or success when the build process ends 🎬'
);
},
};
}
};