File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,21 @@ module.exports = (api) => {
1616
1717 // add import
1818 api . injectImports ( api . entryFile ,
19- `import VueExtensionpoints from 'vue-extensionpoints'` )
19+ `import Extensionpoints from 'vue-extensionpoints'` )
2020}
2121
22- // module.exports.hooks = (api) => {
23- // api.afterInvoke(() => {
24- // const fs = require('fs')
25- // const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
26- // const lines = contentMain.split(/\r?\n/g)
27- // })
28- // }
22+ module . exports . hooks = ( api ) => {
23+ api . afterInvoke ( ( ) => {
24+ const { EOL } = require ( 'os' )
25+ const fs = require ( 'fs' )
26+ const contentMain = fs . readFileSync ( api . entryFile , { encoding : 'utf-8' } )
27+ const lines = contentMain . split ( / \r ? \n / g)
28+
29+ // if not already found, add Vue.use to file
30+ if ( lines . findIndex ( line => line . match ( / V u e .u s e \( E x t e n s i o n p o i n t s \) / ) ) < 0 ) {
31+ const renderIndex = lines . findIndex ( line => line . match ( / n e w V u e / ) )
32+ lines [ renderIndex ] = `Vue.use(Extensionpoints)${ EOL } ${ EOL } ` + lines [ renderIndex ]
33+ fs . writeFileSync ( api . entryFile , lines . join ( EOL ) , { encoding : 'utf-8' } )
34+ }
35+ } )
36+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " vue-cli-plugin-extensionpoints" ,
3- "version" : " 0.1.1 " ,
3+ "version" : " 0.1.2 " ,
44 "description" : " Vue CLI plugin for adding extensionpoints" ,
55 "main" : " index.js" ,
66 "author" :
" Christian González <[email protected] " ,
You can’t perform that action at this time.
0 commit comments