-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install:addon command now throws a friendly error when it runs.
- Loading branch information
1 parent
84590be
commit 2ec5966
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); | ||
}); |