Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleUpdate (type, target) {
logger.debug(type, target)
if (!path.isAbsolute(target)) {
target = path.join(this.context.sourceDir, target)
}
if (target.endsWith('.js')) {
// Bust cache.
delete require.cache[target]
}
this.emit('fileChanged', {
type,
target
})
}
module.exports = (opts, ctx) => {
return {
name: PACKAGE_NAME,
enhanceAppFiles: [
path.join(__dirname, 'client.js')
],
plugins: [
['@vuepress/medium-zoom', true],
],
chainMarkdown(config) {
if (opts.html) {
return
}
// Disable `html` for now. Many yuque writers would write raw HTML in the markdown
// But only these markups under inline code(`) will be transpiled successfully when
// `html` is enabled.
config
.options
.html(false)
function extractCodeFromVueSFC(md, options = {}) {
const root = options.root || path.join(process.cwd(), '../')
md.core.ruler.after('block', 'extract-code', function parser(state) {
let tokens = state.tokens,
tok, i;
// modify html_block
for (i = 0; i < tokens.length; i++) {
tok = tokens[i];
if (tok.type === 'html_block' && isDemoBlock(tok)) {
const handledTokens = getHandledTokens(tok)
if (handledTokens.length) {
tokens.splice(i, 1, ...handledTokens)
i += handledTokens.length - 1
}
}
}
const spawnUpdate = updateType => file => {
const target = path.join(sourceDir, file)
// Bust cache.
delete require.cache[target]
update(`${chalk.red(updateType)} ${chalk.cyan(file)}`)
}
files.forEach(pkg => {
if (pkg.charAt(0) === '.') return
const isPlugin = /^plugin-/.test(pkg)
const desc = isPlugin
? `${pkg.replace('plugin-', '')} plugin for vuepress`
: `${pkg} for vuepress`
const pkgPath = path.join(packagesDir, pkg, `package.json`)
if (!fs.existsSync(pkgPath)) {
const json = {
'name': `@vuepress/${pkg}`,
'version': baseVersion,
'description': desc,
'main': 'index.js',
'publishConfig': {
'access': 'public'
},
'repository': {
'type': 'git',
'url': 'git+https://github.com/vuejs/vuepress.git'
},
'keywords': [
'documentation',
'vue',
constructor (options = {}) {
this.isProd = process.env.NODE_ENV === 'production'
this.options = options
this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback')
logger.debug('sourceDir', this.sourceDir)
if (!fs.existsSync(this.sourceDir)) {
logger.warn(`Source directory doesn't exist: ${chalk.yellow(this.sourceDir)}`)
}
this.vuepressDir = path.resolve(this.sourceDir, '.vuepress')
this.libDir = path.join(__dirname, '../')
}
'documentation',
'vue',
'vuepress',
'generator'
],
'author': 'ULIVZ ',
'license': 'MIT',
'bugs': {
'url': 'https://github.com/vuejs/vuepress/issues'
},
'homepage': `https://github.com/vuejs/vuepress/packages/@vuepress/${pkg}#readme`
}
fs.writeFileSync(pkgPath, JSON.stringify(json, null, 2))
}
const readmePath = path.join(packagesDir, pkg, `README.md`)
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(readmePath, `# @vuepress/${pkg}\n\n> ${desc}`)
}
const npmIgnorePath = path.join(packagesDir, pkg, `.npmignore`)
if (!fs.existsSync(npmIgnorePath)) {
fs.writeFileSync(npmIgnorePath, `__tests__\n__mocks__`)
}
})
getLibFilePath (relative) {
return path.join(this.libDir, relative)
}
'author': 'ULIVZ ',
'license': 'MIT',
'bugs': {
'url': 'https://github.com/vuejs/vuepress/issues'
},
'homepage': `https://github.com/vuejs/vuepress/packages/@vuepress/${pkg}#readme`
}
fs.writeFileSync(pkgPath, JSON.stringify(json, null, 2))
}
const readmePath = path.join(packagesDir, pkg, `README.md`)
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(readmePath, `# @vuepress/${pkg}\n\n> ${desc}`)
}
const npmIgnorePath = path.join(packagesDir, pkg, `.npmignore`)
if (!fs.existsSync(npmIgnorePath)) {
fs.writeFileSync(npmIgnorePath, `__tests__\n__mocks__`)
}
})
constructor (options = {}) {
this.isProd = process.env.NODE_ENV === 'production'
this.options = options
this.sourceDir = this.options.sourceDir || path.join(__dirname, 'docs.fallback')
logger.debug('sourceDir', this.sourceDir)
if (!fs.existsSync(this.sourceDir)) {
logger.warn(`Source directory doesn't exist: ${chalk.yellow(this.sourceDir)}`)
}
this.vuepressDir = path.resolve(this.sourceDir, '.vuepress')
this.libDir = path.join(__dirname, '../')
}