-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-react-app.js
45 lines (41 loc) · 1.27 KB
/
create-react-app.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
const spawn = require('../spawn');
const path = require('path');
const { prompt } = require('enquirer');
const { NPX, CREATE_REACT_APP } = require('../constants.js');
module.exports = app => {
app.task('create-react-app', async () => {
let dest = app.options.name;
if (!dest) {
const answers = await prompt({
type: 'text',
name: 'appName',
message: 'What would you like the app name to be?'
});
dest = answers.appName;
}
await spawn(NPX, [CREATE_REACT_APP, dest]);
});
app.task('create-react-app-templates', async () => {
const dest = path.join(app.cwd, app.options.name);
const answers = await prompt([
{
type: 'text',
name: 'description',
message: 'What description would you like to use for your website?'
},
{
type: 'text',
name: 'title',
message: 'What title would you like to use for your website?'
}
]);
return app
.src('create-react-app/public/*.*', {
cwd: path.join(__dirname, '../../templates')
})
.pipe(app.renderFile('*', answers).on('error', console.error))
.pipe(app.conflicts(dest))
.pipe(app.dest(dest));
});
app.task('default', ['create-react-app', 'create-react-app-templates']);
};