Skip to content

Instantly share code, notes, and snippets.

@konsumer
Created February 19, 2019 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konsumer/4653c9c0bb972a0ad5ad1dc2eaa6a733 to your computer and use it in GitHub Desktop.
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
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