1 | /*!
|
2 | * is-valid-app (https://github.com/jonschlinkert/is-valid-app)
|
3 | *
|
4 | * Copyright (c) 2016, Jon Schlinkert.
|
5 | * Licensed under the MIT License.
|
6 | */
|
7 |
|
8 | ;
|
9 |
|
10 | var utils = require('./utils');
|
11 |
|
12 | module.exports = function(app, name, types) {
|
13 | if (typeof name !== 'string') {
|
14 | throw new TypeError('expected plugin name to be a string');
|
15 | }
|
16 |
|
17 | // if `app` is not a valid instance of `Base`, or if `app` is a valid
|
18 | // instance of Base by not one of the given `types` return false
|
19 | if (!utils.isValid(app, types)) {
|
20 | return false;
|
21 | }
|
22 |
|
23 | // if the `name` has already been registered as a plugin, return false
|
24 | if (utils.isRegistered(app, name)) {
|
25 | return false;
|
26 | }
|
27 |
|
28 | var debug = utils.debug('base:generate:' + name);
|
29 | debug('initializing from <%s>', module.parent.id);
|
30 | return true;
|
31 | };
|