Created
February 19, 2019 03:00
-
-
Save konsumer/4653c9c0bb972a0ad5ad1dc2eaa6a733 to your computer and use it in GitHub Desktop.
Require each file in a directory, and wait for it's `_setup` function to complete
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
const reqGlob = require('require-glob') | |
const run = async () => { | |
const resolvers = await reqGlob('./resolvers/**/*.js') | |
await Object.values(resolvers).reduce( | |
(p, r) => p.then(() => r._setup && r._setup()), | |
Promise.resolve() | |
) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment