@@ -70,7 +70,12 @@ const i18n = new VueI18n({
70
70
71
71
const router = new VueRouter({
72
72
mode: 'history',
73
- routes: [{ path: '/*', component: Test }],
73
+ routes: [{
74
+ path: '/test',
75
+ component: () => import('../components/test/index.vue'),
76
+ }, {
77
+ path: '/*', component: Test
78
+ }],
74
79
});
75
80
76
81
const store = new Vuex.Store({
@@ -113,12 +118,14 @@ const renderTemplate = name => {
113
118
Tooltip : 'tooltip' , // for DemoBox
114
119
} ;
115
120
116
- const demoPaths = fs . readdirSync ( path . join ( __dirname , `../components/${ name } /demo` ) ) ;
117
-
118
- demoPaths . forEach ( demoPath => {
119
- const demo = fs
120
- . readFileSync ( path . join ( __dirname , `../components/${ name } /demo/${ demoPath } ` ) )
121
- . toString ( ) ;
121
+ const demoPaths = fs
122
+ . readdirSync ( path . join ( __dirname , `../components/${ name } /demo` ) )
123
+ . map ( p => `../components/${ name } /demo/${ p } ` ) ;
124
+ const testPaths = fs
125
+ . readdirSync ( path . join ( __dirname , `../components/test` ) )
126
+ . map ( p => `../components/test/${ p } ` ) ;
127
+ [ ...demoPaths , ...testPaths ] . forEach ( demoPath => {
128
+ const demo = fs . readFileSync ( path . join ( __dirname , demoPath ) ) . toString ( ) ;
122
129
123
130
const componentsInDemo = demo . match ( / a - ( \w + ( - \w + ) * ) / g) || [ ] ;
124
131
componentsInDemo . forEach ( name => {
@@ -147,6 +154,22 @@ const renderTemplate = name => {
147
154
fs . writeFileSync ( OUTPUT_PATH , template ) ;
148
155
} ;
149
156
157
+ function fsExistsSync ( path ) {
158
+ try {
159
+ fs . accessSync ( path , fs . F_OK ) ;
160
+ } catch ( e ) {
161
+ return false ;
162
+ }
163
+ return true ;
164
+ }
165
+
166
+ if ( ! fsExistsSync ( path . join ( __dirname , '../components/test/index.vue' ) ) ) {
167
+ if ( ! fsExistsSync ( path . join ( __dirname , '../components/test' ) ) ) {
168
+ fs . mkdirSync ( path . join ( __dirname , '../components/test' ) ) ;
169
+ }
170
+ fs . writeFileSync ( path . join ( __dirname , '../components/test/index.vue' ) , `<template></template>` ) ;
171
+ }
172
+
150
173
let demoWatcher ;
151
174
152
175
chokidar . watch ( configPath , { ignoreInitial : true } ) . on ( 'change' , async ( ) => {
0 commit comments