Last active
June 14, 2017 19:37
-
-
Save georgesboris/79d851a030423fac3a3a8a5b375a2616 to your computer and use it in GitHub Desktop.
self importing firebase-functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Require all functions files. | |
* /src/{function}/{function}.js | |
* | |
* functions must export | |
* { | |
* key: string the name of the function, | |
* watcher: fn the firebase-function watcher function | |
* } | |
* | |
*/ | |
let functions = []; | |
require('fs').readdirSync(__dirname + '/src/').forEach(function(file) { | |
if (!file.startsWith('.')) { | |
require(`./src/${file}/${file}`)(functions); | |
} | |
}); | |
/** | |
* Export functions | |
*/ | |
functions.forEach((fn) => { | |
exports[fn.key] = fn.watcher; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment