Created
January 12, 2017 16:27
-
-
Save einarlove/e2ea46b78463aa08542c604893d71d19 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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