home
  • Blog
  • Introduction
  • Basic use
  • Advanced use
  • Writing addons
    • Addon structure
    • Tutorial - writing your first addon
    • Addon dependencies
    • Addon blueprints
    • In Repo Addons
    • Custom Commands
    • Writing documentation
    • Deprecating addon features
  • API documentation
  • Appendix

Custom Commands


You can extend the functionality provided by Ember CLI by creating new CLI commands. For example, if you wanted to enable developers to deploy an app from the command line with ember deploy, you could create an addon that includes a "deploy" command that the app can find.

To do this, in an addon's index.js file, add the includedCommands() function and return an object pointing to the command.

index.js
module.exports = {
  name: require('./package').name,

  includedCommands() {
    return {
      'deploy': {
        name: 'deploy',
        works: 'insideProject',
        description: 'Deploys the app to my production host!',
        availableOptions: [],

        run() {
          // deploy!
        }
      },
    }
  }
};

The API for this object is documented here.

By convention, addon authors will store commands in the lib/commands directory of the addon, and include them using require('./lib/commands'), but this is not necessary.

You can see additional examples of addons that implement custom commands, by searching for includedCommands in Ember Observer's code search!

left arrow
In Repo Addons
Writing documentation
right arrow
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2024 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.