// generates a feature story import * as _ from "lodash"; import * as fs from "fs-extra"; import { getRelativePath, getRelativeProjectPath } from "../../lib/files"; export const generateFeatureStory = (content: any, outputPath: string) => { const templateFolder: string = getRelativeProjectPath( "./src/commands/scaffold/templates" ); fs.readFile( `${templateFolder}/Feature.stories.tsx.template`, "utf8", (err, data) => { if (err) return console.log(err); // grab [name] from the item // grab [description] from the item const { name, description } = content; // pass in [name], [description] to Feature.stories.tsx.template const storiesTsx = _.template(data)({ name, description }); // save result to {outFolder}/components/[Name]/[Name].tsx fs.outputFile( `${getRelativePath(outputPath)}/${name}.stories.tsx`, storiesTsx ); } ); };