Modifying ember build / serve command options


#1

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.


#2

The info on flags is controlled by the availableOptions hash here: https://github.com/ember-cli/ember-cli/blob/master/lib/commands/build.js

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:


#3

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?


#4

It looks like you may need to override the build command with your own extension. When doing a code search on Ember Observer (https://emberobserver.com/code-search?codeQuery=availableOptions) the closest I find is this: https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/build.js#L13

Which does look like what you are after …


#5

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