open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
226 stars 37 forks source link

HOWTO pass custom cli arguments to `analyze` that a plugin can work on? #223

Closed LorenzKahl closed 8 months ago

LorenzKahl commented 8 months ago

In my custom CEM plugin I would like to generate a different output for prod / dev environments.

I tried calling the analyzer providing a custom argument environment:

cem analyze --litelement --environment="production"

But it fails with the following error: > Uncaught UNKNOWN_OPTION: Unknown option: --environment

Is there a better way to achieve this that I am missing?

thepassle commented 8 months ago

You can use process.env for this, e.g.:

FOO=BAR cem analyze

And then in your plugin you can do:

if(process.env.FOO === 'bar') {}