-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.js
47 lines (39 loc) · 994 Bytes
/
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
'use strict';
var path = require('path');
var isValid = require('is-valid-app');
module.exports = function(app) {
// return if the generator is already registered
if (!isValid(app, 'generate-react')) return;
/**
* Generate a `index.js` file to the current working directory. Learn how to [customize
* behavior(#customization) or override built-in templates.
*
* ```sh
* $ gen react:react
* ```
* @name react:react
* @api public
*/
task(app, 'react', 'index.js');
/**
* Alias for running the [react](#react) task with the following command:
*
* ```sh
* $ gen react
* ```
* @name react
* @api public
*/
app.task('default', ['react']);
};
/**
* Create a task with the given `name` and glob `pattern`
*/
function task(app, name, pattern) {
app.task(name, function() {
return app.src(pattern, {cwd: __dirname})
.pipe(app.renderFile('*'))
.pipe(app.conflicts(app.cwd))
.pipe(app.dest(app.cwd));
});
}