UNPKG

ember-cli

Version:

Command line tool for developing ambitious ember.js apps

68 lines (52 loc) 1.88 kB
'use strict'; var Command = require('../models/command'); var Promise = require('../ext/promise'); var merge = require('lodash-node/modern/objects/merge'); var SilentError = require('../errors/silent'); module.exports = Command.extend({ name: 'destroy', description: 'Destroys code generated by `generate` command.', aliases: ['d'], works: 'insideProject', availableOptions: [ { name: 'dry-run', type: Boolean, default: false }, { name: 'verbose', type: Boolean, default: false }, { name: 'pod', type: Boolean, default: false } ], anonymousOptions: [ '<blueprint>' ], run: function(commandOptions, rawArgs) { var blueprintName = rawArgs[0]; var entityName = rawArgs[1]; if (!blueprintName) { return Promise.reject(new SilentError('The `ember destroy` command requires a ' + 'blueprint name to be specified. ' + 'For more details, use `ember help`.')); } if (!entityName) { return Promise.reject(new SilentError('The `ember destroy` command requires an ' + 'entity name to be specified. ' + 'For more details, use `ember help`.')); } var Task = this.tasks.DestroyFromBlueprint; var task = new Task({ ui: this.ui, analytics: this.analytics, project: this.project }); var taskArgs = { args: rawArgs }; var taskOptions = merge(taskArgs, commandOptions || {}); if (this.project.initializeAddons) { this.project.initializeAddons(); } return task.run(taskOptions); }, printDetailedHelp: function() { var ui = this.ui; ui.writeLine(''); ui.writeLine(' Run `ember help generate` to view a list of available blueprints.'); } });