Skip to content

Instantly share code, notes, and snippets.

View beatak's full-sized avatar
🍄
Mushroom

Takashi M beatak

🍄
Mushroom
  • San Francisco, CA
View GitHub Profile
var wrap_spawn = function (arg_spawn, cb_on_close) {
var child = spawn.apply(null, arg_spawn);
var stdout = [];
var stderr = [];
child.stdout.on('data', function (data) {
stdout.push(data.toString());
});
child.stderr.on('data', function (data) {
stderr.push(data.toString());
});
@dnephin
dnephin / compose-hooks.sh
Last active October 21, 2022 20:44
Execute a hook in './hooks/<service>/<action>' when that event is received
#!/bin/bash
set -e
function handle_event() {
local entry="$1"
local action=$(echo $entry | jq -r '.action')
local service=$(echo $entry | jq -r '.service')
local hook="./hooks/$service/$action"
if [ -x "$hook" ]; then
"$hook" "$entry"