Skip to content

Instantly share code, notes, and snippets.

@einarlove
Created January 12, 2017 16:27
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 einarlove/e2ea46b78463aa08542c604893d71d19 to your computer and use it in GitHub Desktop.
Save einarlove/e2ea46b78463aa08542c604893d71d19 to your computer and use it in GitHub Desktop.
import path from 'path'
import fs from 'fs'
export default root => {
const stories = []
const loopFiles = context => {
fs.readdirSync(context).forEach(name => {
const filepath = path.join(context, name)
if (fs.lstatSync(filepath).isDirectory()) {
loopFiles(filepath)
}
if (/story\.js$/.test(name)) {
stories.push(filepath)
}
})
}
loopFiles(root)
return stories
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment