提交 a63f3aed 编写于 作者: U ULIVZ

fix: enhance app doesn't work due to interface change

上级 b20c23bd
......@@ -8,7 +8,7 @@ import dataMixin from './dataMixin'
import store from './store'
import { routes } from '@temp/routes'
import { siteData } from '@temp/siteData'
import appEnhancers from '@temp/appEnhancers.js'
import appEnhancers from '@temp/app-enhancers.js'
// suggest dev server restart on base change
if (module.hot) {
......
......@@ -11,7 +11,7 @@ module.exports = class Tapable {
*/
tap (name, value) {
if (Array.isArray(value)) {
this.items.push(value.map(i => ({ value: i, name })))
return this.items.push(...value.map(i => ({ value: i, name })))
}
this.items.push({ value, name })
}
......
......@@ -6,34 +6,36 @@ const { pathsToModuleCode } = require('../../prepare/codegen')
const logger = require('../../util/logger')
module.exports = class EnhanceAppFilesOption extends Tapable {
add (value, pluginName) {
tap (pluginName, value) {
if (typeof value === 'function') {
value = value()
}
super.add(value, pluginName)
super.tap(pluginName, value)
}
async run (...args) {
const manifest = []
console.log(this.items)
// 1. write enhance app files.
for (const [index, value] of this.items.entries()) {
const { filepath, pluginName } = value
const { value: filepath, name: pluginName } = value
if (fs.existsSync(filepath)) {
const destPath = await writeTemp(
`enhance-app-files/${index}.js`,
`app-enhancers/enhancer-${index}.js`,
`export { default } from ${JSON.stringify(filepath)}`
)
manifest.push(destPath)
} else {
logger.debug(
chalk.gray(`[vuepress-plugin-${pluginName}]`) +
chalk.gray(`[vuepress-plugin-${pluginName}] `) +
`${chalk.cyan(filepath)} Not Found.`
)
}
}
// 2. write entry file.
await writeTemp('appEnhancers.js', pathsToModuleCode(manifest))
await writeTemp('app-enhancers.js', pathsToModuleCode(manifest))
}
}
export default function (Vue) {
Vue.use(/**/)
export default function ({ Vue }) {
console.warn('[vuepress-plugin-test] enhancing !!!')
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册