Skip to content

Commit

Permalink
chore(commands): override ng destroy
Browse files Browse the repository at this point in the history
It's common for users to try and do `ng destroy component name` and have
it only partially work.

Since we don't support the command, it's better to not have it do any
partial operations.
  • Loading branch information
filipesilva committed Oct 17, 2016
1 parent b250cb6 commit 0671011
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/angular-cli/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
'serve': require('../commands/serve').default,
'new': require('../commands/new').default,
'generate': require('../commands/generate').default,
'destroy': require('../commands/destroy').default,
'init': require('../commands/init').default,
'test': require('../commands/test').default,
'e2e': require('../commands/e2e').default,
Expand Down
20 changes: 20 additions & 0 deletions packages/angular-cli/commands/destroy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const Command = require('ember-cli/lib/models/command');
const SilentError = require('silent-error');


const DestroyCommand = Command.extend({
name: 'destroy',
aliases: ['d'],
works: 'insideProject',

anonymousOptions: [
'<blueprint>'
],

run: function() {
return Promise.reject(new SilentError('The destroy command is not supported by Angular-CLI.'));
}
});

export default DestroyCommand;
DestroyCommand.overrideCore = true;
1 change: 1 addition & 0 deletions packages/angular-cli/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const lookupCommand = require('ember-cli/lib/cli/lookup-command');

const commandsToIgnore = [
'easter-egg',
'destroy',
'github-pages-deploy' // errors because there is no base github-pages command
];

Expand Down
41 changes: 41 additions & 0 deletions tests/acceptance/destroy.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

const ng = require('../helpers/ng');
const tmp = require('../helpers/tmp');
const conf = require('ember-cli/tests/helpers/conf');
const expect = require('chai').expect;

describe('Acceptance: ng destroy', function () {
before(conf.setup);

after(conf.restore);

beforeEach(function () {
this.timeout(10000);
return tmp.setup('./tmp').then(function () {
process.chdir('./tmp');
}).then(function () {
return ng(['new', 'foo', '--skip-npm', '--skip-bower']);
});
});

afterEach(function () {
return tmp.teardown('./tmp');
});

it('without args should fail', function () {
return ng(['destroy']).then(() => {
throw new SilentError(`ng destroy should fail.`);
}, (err) => {
expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.');
});
});

it('with args should fail', function () {
return ng(['destroy', 'something']).then(() => {
throw new SilentError(`ng destroy something should fail.`);
}, (err) => {
expect(err.message).to.equal('The destroy command is not supported by Angular-CLI.');
});
});
});

0 comments on commit 0671011

Please sign in to comment.