-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
57 lines (45 loc) · 1018 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
/**
* Register the plugin.
*
* ```js
* var collections = require('verb-collections');
*
* // in your generator
* app.use(collections());
* ```
* @api public
*/
function collections(options) {
options = options || {};
return function plugin(app, base) {
if (!isValidInstance(app)) return;
app.option(base.options);
app.option(options);
app.create('badges', { viewType: 'partial' });
app.create('docs', { viewType: 'partial' });
app.use(require('generate-collections'));
return plugin;
};
}
/**
* Validate instance
*/
function isValidInstance(app) {
if (!app.isApp && !app.isGenerator && !app.isVerb) {
return false;
}
if (app.isRegistered('verb-collections')) {
return false;
}
return true;
}
/**
* Expose `plugin` function so that verb-collections
* can be run as a global generator
*/
module.exports = collections();
/**
* Expose `collection` function so that options can be passed
*/
module.exports.create = collections;