ngneat / svg-icon

👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
https://netbasal.com
MIT License
260 stars 35 forks source link

Make multi-config possible for svg-generator #64

Closed qortex closed 2 years ago

qortex commented 2 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Right now, a single config can be used because of this line: https://github.com/ngneat/svg-icon/blob/0c08b506f32c342a8c0f10e3ba01025892a3ec8a/svg-generator/index.ts#L7

A single config can be specified (unless I don't know how to do it?)

What is the motivation / use case for changing the behavior?

In a Nx monorepo setting with multiple apps that use different svg assets, I'd like to be able to launch svg-generator with multiple configs.

Specifying the directory where the config lookup should start with cosmiconfig would be enough for me to setup various Nx executors with their own configs.

Maybe a command line argument would do the trick?

NetanelBasal commented 2 years ago

You're welcome to create a PR

qortex commented 2 years ago

Cool! Does the solution with argv look good to you?

Not experienced with node.js script, but will look up the good practices in that regard.

NetanelBasal commented 2 years ago

Can you show an example, please?

qortex commented 2 years ago

explorerSync.search() would be replaced with explorerSync.search([directoryGivenInArgv]) when this directory is given:

yarn run svg-generator --configDirectory="libs/myapp/shared/icons"

That would make the config search start from this folder as documented here: https://github.com/davidtheclark/cosmiconfig#explorersearch

As opposed to now where the config has to be at the root of the whole workspace (in a config file or in package.json).

NetanelBasal commented 2 years ago

LGTM