Skip to content

Commit

Permalink
install:addon command now throws a friendly error when it runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielOchoa committed Apr 8, 2015
1 parent 84590be commit 2ec5966
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
21 changes: 21 additions & 0 deletions lib/commands/install-addon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var Command = require('../models/command');
var SilentError = require('../errors/silent');
var Promise = require('../ext/promise');

module.exports = Command.extend({
name: 'install:addon',
description: 'Deprecated. You can use `ember install` for ember-cli addons.',
works: 'insideProject',

anonymousOptions: [
'<addon-name>'
],

run: function() {
var err = 'This command has been deprecated. Please use `ember install ';
err += '<addonName>` instead.';
return Promise.reject(new SilentError(err));
}
});
2 changes: 1 addition & 1 deletion lib/commands/install-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Promise = require('../ext/promise');

module.exports = Command.extend({
name: 'install:npm',
description: 'Npm package installs are now managed by the user.',
description: 'Deprecated. Npm package installs are now managed by the user.',
works: 'insideProject',

anonymousOptions: [
Expand Down
47 changes: 47 additions & 0 deletions tests/unit/commands/install-addon-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

var expect = require('chai').expect;
var InstallAddonCommand = require('../../../lib/commands/install-addon');
var commandOptions = require('../../factories/command-options');

describe('install:addon command', function() {
var command, options, msg;
before(function() {
options = commandOptions({
settings: {},
project: {
name: function() {
return 'some-random-name';
},
isEmberCLIProject: function() {
return true;
}
}
});

command = new InstallAddonCommand(options);

msg = 'This command has been deprecated. Please use `ember install ';
msg += '<addonName>` instead.';
});

describe('with args', function() {
it('gives a helpful message if no arguments are passed', function() {
return command.validateAndRun(['ember-cli-cordova']).then(function() {
expect(false, 'should reject with error');
}).catch(function(err) {
expect(err.message).to.equal(msg, 'expect error to have a helpful message');
});
});
});

describe('without args', function() {
it('gives a helpful message if no arguments are passed', function() {
return command.validateAndRun([]).then(function() {
expect(false, 'should reject with error');
}).catch(function(err) {
expect(err.message).to.equal(msg, 'expect error to have a helpful message');
});
});
});
});

0 comments on commit 2ec5966

Please sign in to comment.