Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow automatic station directories #12

Open
e110c0 opened this issue Jun 6, 2018 · 3 comments
Open

allow automatic station directories #12

e110c0 opened this issue Jun 6, 2018 · 3 comments

Comments

@e110c0
Copy link
Contributor

e110c0 commented Jun 6, 2018

right now, for every scene, we have to add scenes/[name]/elements to the station.

it would be really nice to have a wildcard entry scenes/*/elements and then populate this with all existing scenes

@michaelzoidl
Copy link
Member

michaelzoidl commented Jun 6, 2018

So something like?

λ  myproject git:(master) ✗ takeoff
? What do you want to create? component
? component-name my-component
? Choose a destination for the component (Use arrow keys)
❯ element
  scene
  scene/authenticate/element
  scene/landingpage/element
  scene/[*]/element (create element in all available scenes)

@e110c0
Copy link
Contributor Author

e110c0 commented Jun 6, 2018

cut the last line, and in the station, the destinations should be:

[
  'element',
  'scene',
  'scene/*/element'
]

and when you run it you get

? Choose a destination for the component (Use arrow keys)
❯ element
  scene
  scene/authenticate/element
  scene/landingpage/element

@e110c0
Copy link
Contributor Author

e110c0 commented Jun 13, 2018

basically this with a nice syntax:

const dirs = p => readdirSync(p).filter(f => statSync(join(p, f)).isDirectory());

const sceneElementDirs = dirs('src/components/scenes')
  .map( d => `scenes/${d}/elements` );

choices: [ ...choices, ...sceneElementDirs ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants