@@ -13,6 +13,8 @@ const metadata = require('../../lib/options')
13
13
const { isLocalPath, getTemplatePath } = require ( '../../lib/local-path' )
14
14
15
15
const MOCK_META_JSON_PATH = path . resolve ( './test/e2e/mock-meta-json' )
16
+ const MOCK_METALSMITH_CUSTOM_PATH = path . resolve ( './test/e2e/mock-metalsmith-custom' )
17
+ const MOCK_METALSMITH_CUSTOM_BEFORE_AFTER_PATH = path . resolve ( './test/e2e/mock-metalsmith-custom-before-after' )
16
18
const MOCK_TEMPLATE_REPO_PATH = path . resolve ( './test/e2e/mock-template-repo' )
17
19
const MOCK_TEMPLATE_BUILD_PATH = path . resolve ( './test/e2e/mock-template-build' )
18
20
const MOCK_METADATA_REPO_JS_PATH = path . resolve ( './test/e2e/mock-metadata-repo-js' )
@@ -120,6 +122,46 @@ describe('vue-cli', () => {
120
122
} )
121
123
} )
122
124
125
+ it ( 'supports custom metalsmith plugins' , done => {
126
+ generate ( 'test' , MOCK_METALSMITH_CUSTOM_PATH , MOCK_TEMPLATE_BUILD_PATH , err => {
127
+ if ( err ) done ( err )
128
+
129
+ expect ( exists ( `${ MOCK_TEMPLATE_BUILD_PATH } /custom/readme.md` ) ) . to . equal ( true )
130
+
131
+ async . eachSeries ( [
132
+ 'readme.md'
133
+ ] , function ( file , next ) {
134
+ const template = fs . readFileSync ( `${ MOCK_METALSMITH_CUSTOM_PATH } /template/${ file } ` , 'utf8' )
135
+ const generated = fs . readFileSync ( `${ MOCK_TEMPLATE_BUILD_PATH } /custom/${ file } ` , 'utf8' )
136
+ render ( template , { custom : 'Custom' } , ( err , res ) => {
137
+ if ( err ) return next ( err )
138
+ expect ( res ) . to . equal ( generated )
139
+ next ( )
140
+ } )
141
+ } , done )
142
+ } )
143
+ } )
144
+
145
+ it ( 'supports custom metalsmith plugins with after/before object keys' , done => {
146
+ generate ( 'test' , MOCK_METALSMITH_CUSTOM_BEFORE_AFTER_PATH , MOCK_TEMPLATE_BUILD_PATH , err => {
147
+ if ( err ) done ( err )
148
+
149
+ expect ( exists ( `${ MOCK_TEMPLATE_BUILD_PATH } /custom-before-after/readme.md` ) ) . to . equal ( true )
150
+
151
+ async . eachSeries ( [
152
+ 'readme.md'
153
+ ] , function ( file , next ) {
154
+ const template = fs . readFileSync ( `${ MOCK_METALSMITH_CUSTOM_BEFORE_AFTER_PATH } /template/${ file } ` , 'utf8' )
155
+ const generated = fs . readFileSync ( `${ MOCK_TEMPLATE_BUILD_PATH } /custom-before-after/${ file } ` , 'utf8' )
156
+ render ( template , { before : 'Before' , after : 'After' } , ( err , res ) => {
157
+ if ( err ) return next ( err )
158
+ expect ( res ) . to . equal ( generated )
159
+ next ( )
160
+ } )
161
+ } , done )
162
+ } )
163
+ } )
164
+
123
165
it ( 'generate a vaild package.json with escaped author' , done => {
124
166
monkeyPatchInquirer ( escapedAnswers )
125
167
generate ( 'test' , MOCK_TEMPLATE_REPO_PATH , MOCK_TEMPLATE_BUILD_PATH , err => {
@@ -254,7 +296,7 @@ describe('vue-cli', () => {
254
296
expect ( getTemplatePath ( '../template' ) ) . to . equal ( path . join ( __dirname , '/../../../template' ) )
255
297
} )
256
298
257
- it . only ( 'points out the file in the error' , done => {
299
+ it ( 'points out the file in the error' , done => {
258
300
monkeyPatchInquirer ( answers )
259
301
generate ( 'test' , MOCK_ERROR , MOCK_TEMPLATE_BUILD_PATH , err => {
260
302
expect ( err . message ) . to . match ( / ^ \[ r e a d m e \. m d \] P a r s e e r r o r / )
0 commit comments