@@ -18,20 +18,24 @@ const quickRebuildSequence = [
18
18
"gatsby build"
19
19
// Add custom commands here
20
20
] ;
21
- // You can also create your custom callback terminal sequences...
21
+ // You can also create your custom callback terminal command sequences...
22
22
23
- // Routing (Gatsby Update/Re-build sequences) //
23
+ // Routing with callback terminal command sequences //
24
24
// Default delay is 120 and 30s respectively = build will trigger only after inactivity for 2 minutes, to not to repeat the same thing multiple times.
25
25
createGatsbyWebhook ( '/clean_gatsby_rebuild/' , cleanRebuildSequence , 120000 )
26
26
createGatsbyWebhook ( '/quick_gatsby_rebuild/' , quickRebuildSequence , 30000 )
27
27
// You can also create custom webhook callbacks with your custom sequences...
28
28
29
29
// FUNCTIONS //
30
30
31
- /* FUNCTION: Create Gatsby webhook route.
32
- endpoint(string) "/test/" - endpoint path
33
- sequence(array) [string, ...] - callback commands, will be executed synchronously in order, same as "commands" in runSequence()
34
- delay(int) - delay in ms. The action will be fired only after inactivity of receiving the same request within delay period.
31
+ /*
32
+ FUNCTION: Create Gatsby webhook route.
33
+ Accepts:
34
+ endpoint(string) "/test/" - endpoint path
35
+ sequence(array) [string, ...] - callback commands, will be executed synchronously in order, same as "commands" in runSequence()
36
+ delay(int) - delay in ms. The action will be fired only after inactivity of receiving the same request within delay period.
37
+ Returns:
38
+ HTTP 200 OK || console.log
35
39
*/
36
40
function createGatsbyWebhook ( endpoint , sequence , delay = 15000 ) {
37
41
gatsbyWebhookHelper . post ( endpoint , ( req , res ) => {
@@ -47,8 +51,12 @@ function createGatsbyWebhook(endpoint, sequence, delay = 15000){
47
51
} ) ;
48
52
}
49
53
50
- /* FUNCTION: Run Terminal Sequence.
51
- commands(array) [string, ...] - callback commands, will be executed synchronously in order.
54
+ /*
55
+ FUNCTION: Run Terminal Sequence.
56
+ Accepts:
57
+ commands(array || false) [string, ...] - callback commands, will be executed synchronously in order.
58
+ Returns:
59
+ status(boolean) - success is true, failure is false
52
60
*/
53
61
function runSequence ( commands = false ) {
54
62
if ( commands === false ) return false ;
@@ -79,6 +87,8 @@ function runSequence (commands=false){
79
87
return true ;
80
88
}
81
89
90
+ // /FUNCTIONS //
91
+
82
92
// Start //
83
93
function start_gatsby_webhook_listener ( ) {
84
94
gatsbyWebhookHelper . listen ( WEBHOOK_PORT , ( ) => console . log ( 'Node Webhook helper started on port ' + String ( WEBHOOK_PORT ) ) ) ;
0 commit comments