-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.js
50 lines (42 loc) · 1.15 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
'use strict';
var path = require('path');
var isValid = require('is-valid-app');
module.exports = app => {
// return if the generator is already registered
if (!isValid(app, 'generate-react')) return;
app.use(require('generate-project'));
app.register('create-react-app', require('./lib/generators/create-react-app'));
app.register('custom-test', require('./lib/generators/custom-tests'));
/**
* 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
*/
/**
* Alias for running the [react](#react) task with the following command:
*
* ```sh
* $ gen react
* ```
* @name react
* @api public
*/
app.task('default', ['project']);
};
/**
* Create a task with the given `name` and glob `pattern`
*/
function task(app, name, pattern, dest = '') {
app.task(name, () => {
return app
.src(pattern, { cwd: __dirname })
.pipe(app.renderFile('*'))
.pipe(app.conflicts(app.cwd))
.pipe(app.dest(path.join(app.cwd, dest)));
});
}