-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
50 lines (39 loc) · 1.14 KB
/
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
'use strict';
var path = require('path');
var clone = require('clone-deep');
var utils = require('./utils');
module.exports = function plugin(app) {
if (!utils.isValid(app, 'verb-repo-data')) return;
// clone user-defined data before extending
var data = clone(app.cache.data);
/**
* Plugins
*/
app.use(require('generate-data'));
/**
* Format license field for readmes
*/
app.data('licenseStatement', formatLicense(app));
// restore user-defined data
app.data(data);
};
/**
* Create a license statement from `license` in from package.json
* @param {Object} `app`
* @param {Object} `val` License string in package.json
* @param {Object} `config` package.json config object
*/
function formatLicense(app) {
var license = app.options.license || app.cache.data.license || 'MIT';
if (/^(Released|Licensed)/.test(license)) {
return license;
}
var fp = path.resolve(app.cwd, 'LICENSE');
if (utils.exists(fp)) {
var url = utils.repo.file(app.cache.data.repo, 'LICENSE');
license = '[' + license + ' License](LICENSE).';
} else {
license += ' License.';
}
return 'Released under the ' + license;
}