diff --git a/hooks.js b/hooks.js new file mode 100644 index 0000000..d5614f1 --- /dev/null +++ b/hooks.js @@ -0,0 +1,38 @@ +const fs = require('fs').promises; +const ms = require('ms'); +const os = require('os'); +const path = require('path'); + +const getHooksRoot = () => path.join(os.homedir(), '/.syncthing-hooks'); + +const readHooksRoot = async root => { + try { + const files = await fs.readdir(root); + return files; + } catch { + return []; + } +}; + +const parseHooks = (root, hooks) => + hooks + .map(x => ({ + path: path.join(root, x), + match: x.match(/(?.{11})-(?