forked from tspringborg/mola-nuxt-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsao.js
61 lines (56 loc) · 1.47 KB
/
sao.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
const glob = require('glob')
const { join } = require('path')
const spawn = require('cross-spawn')
const rootDir = __dirname
const move = (from, to = '') => {
const result = {}
const options = { cwd: join(rootDir, 'template'), nodir: true, dot: true }
for (const file of glob.sync(`${from}/**`, options)) {
result[file] = (to ? to + '/' : '') + file.replace(`${from}/`, '')
}
return result
}
module.exports = {
prompts: {
name: {
message: 'Project name',
default: ':folderName:',
},
description: {
message: 'Description',
default: 'A mola-nuxt-app'
},
author: {
type: 'string',
message: 'Author name',
default: ':gitUser:',
store: true
},
},
move(answers) {
const moveable = {
gitignore: '.gitignore',
'_package.json': 'package.json',
'_.eslintrc.js': '.eslintrc.js',
}
return Object.assign(
moveable,
move('nuxt')
)
},
post(
{ npmInstall, gitInit, chalk, isNewFolder, folderName, folderPath },
{ meta }
) {
gitInit()
npmInstall()
console.log()
const run = spawn.sync('npm', ['run', 'dev'], {
cwd: folderPath,
stdio: 'inherit',
})
run.stderr.on('data', (data) => {
console.log(`${data}`);
})
}
}