Astrocoders / gen

As simple as a generator can be
MIT License
7 stars 0 forks source link

Allow one template to trigger another generator #1

Open fakenickels opened 6 years ago

fakenickels commented 6 years ago
module.exports.where = ({ name }) => `re/scenes/${name}.re`

module.exports.args = { name: 'Scene name' }

module.exports.gen = ({ name }, { commonTags: { stripIndent } }) => stripIndent`open Rebolt;
open NavigationConfig;
let component = ReasonReact.statelessComponent("${name}");
let make = (~navigation, _children) => {
  ...component,
  render: _self =>
    <StackNavigator.Screen headerTitle="${name}" navigation>
      ...(() => <View> <Text> ("${name}" |> ReasonReact.string) </Text> </View>)
    </StackNavigator.Screen>,
};`

module.exports.postBuild = ({name}, { gen: { trigger } }) => {
  console.log(
    '✅ ',
    chalk.green(
      `Generated ${name} scene, gonna generate`,
    ),
  )

 trigger(something here to trigger other)
}