1 | const path = require('path');
|
2 |
|
3 | const { json, template } = require('mrm-core');
|
4 |
|
5 | module.exports = () => {
|
6 | const pkg = json('package.json');
|
7 |
|
8 |
|
9 | const readme = template(
|
10 | 'README.md',
|
11 | path.join(__dirname, '../../templates/README.md')
|
12 | );
|
13 |
|
14 | if (!readme.exists()) {
|
15 | const startCase = (name) =>
|
16 | name.replace(name.charAt(0), name.charAt(0).toUpperCase());
|
17 |
|
18 | readme
|
19 | .apply({
|
20 | title: pkg
|
21 | .get('name')
|
22 | .split('-')
|
23 | .map((name) => startCase(name))
|
24 | .join(' '),
|
25 | name: pkg
|
26 | .get('name')
|
27 | .replace(/(-loader|-webpack-plugin)$/, '')
|
28 | .split('-')
|
29 | .map((name) => startCase(name))
|
30 | .join(''),
|
31 | package: pkg.get('name'),
|
32 | description: pkg.get('description') || '',
|
33 | })
|
34 | .save();
|
35 | }
|
36 | };
|