-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
generator.js
73 lines (61 loc) · 1.5 KB
/
generator.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
var isValid = require('is-valid-app');
module.exports = function(app) {
if (!isValid(app, 'generate-readme')) return;
/**
* Plugins
*/
app.use(require('generate-defaults'));
/**
* Alias for the [readme:node](#node) task, to allow this generator to be
* run with the following command:
*
* ```sh
* $ gen readme
* $ gen readme --dest ./docs
* ```
* @name default
* @api public
*/
app.task('default', ['readme-node']);
app.task('readme', ['readme-node']);
/**
* Generate a basic `README.md` for a node.js project to the current working
* directory or specified `--dest`.
*
* ```sh
* $ gen readme:node
* $ gen readme:node --dest ./docs
* ```
* @name node
* @api public
*/
app.task('node', ['readme-node']);
app.task('readme-node', function() {
return file(app, 'node');
});
/**
* Generate a minimal `README.md` to the current working directory or specified `--dest`.
* Also aliased as `readme-minimal` to provide a semantic task name for plugin usage.
*
* ```sh
* $ gen readme:min
* ```
* @name min
* @api public
*/
app.task('min', ['readme-minimal']);
app.task('minimal', ['readme-minimal']);
app.task('readme-minimal', function() {
return file(app, 'minimal');
});
};
/**
* Generate a file
*/
function file(app, name) {
return app.src(`templates/${name}.md`, { cwd: __dirname })
.pipe(app.renderFile('*'))
.pipe(app.conflicts(app.cwd))
.pipe(app.dest(app.cwd));
}