Modifying ember build / serve command options

Hi,

i am currently writing an ember-cli addon that modifies some files before the actual build (using the addon hooks preprocessTree). The behavior of the plugin is controlled via command line arguments:

ember build --myflag VALUE

This is working as intended, but on each build I am getting a warning like:

The option '--myflag' is not registered with the build command. Run `ember build --help` for a list of supported options.
  • Is there a possibility to make that warning go away?
  • Can I go even further and provide the information of what the flag does to ember build --help ?

I dont want to overwrite the complete build (and serve) command by extending the ServeCommand and BuildCommand classes coming with ember-cli - only to shut of that warning, because this would certainly be an overkill to my requirements as I dont change the fundamental behavior of these commands and only use an hook that is provided by the Addon class.

The info on flags is controlled by the availableOptions hash here: ember-cli/build.js at master · ember-cli/ember-cli · GitHub

I haven’t tried, but if you add your own info about your flag does the warning go away? Would love to know for future reference :wink:

1 Like

Thanks for your reply!

Yes, but the problem is, how can I access the availableOptions from my addon? I did not find a way yet?

It looks like you may need to override the build command with your own extension. When doing a code search on Ember Observer (Ember Observer) the closest I find is this: ember-electron/build.js at main · adopted-ember-addons/ember-electron · GitHub

Which does look like what you are after …

1 Like

Thanks for your efforts! I will try it this way! :blush: