-
Notifications
You must be signed in to change notification settings - Fork 2
/
new.js
53 lines (48 loc) · 1.03 KB
/
new.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
const fs = require('fs')
const path = require('path')
const dir = `src/pages/${process.argv[2]}`
function mkdir(dir) {
if (!fs.existsSync(path.dirname(dir))) mkdir(path.dirname(dir))
fs.mkdirSync(dir)
}
mkdir(dir)
const jsContent = `import 'src/js/base'
import init from 'src/js/init'
import App from './App.vue'
import './app.less'
init().then(user => {
new Vue({
render: h => h(App, {
props: { user }
})
}).$mount('app')
}).catch(error => console.error(error))
`
const lessContent = `@import (reference) "~src/less/Mixins";`
const vueContent = `<template>
<div id="app">
<nav-bar :user="user"></nav-bar>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {}
},
props: {
user: Object
},
methods: {},
created() {}
}
</script>`
fs.writeFile(`${dir}/app.js`, jsContent, err => {
if (err) throw err
})
fs.writeFile(`${dir}/app.less`, lessContent, err => {
if (err) throw err
})
fs.writeFile(`${dir}/App.vue`, vueContent, err => {
if (err) throw err
})