Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(markdown): add error logger for importCode plugin #1273

Merged
merged 1 commit into from Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,4 +1,4 @@
import { fs, path } from '@vuepress/utils'
import { colors, fs, logger, path } from '@vuepress/utils'
import type { MarkdownEnv } from '../../types.js'
import type { ImportCodeTokenMeta } from './types.js'

Expand All @@ -15,6 +15,9 @@ export const resolveImportCode = (
// if the importPath is relative path, we need to resolve it
// according to the markdown filePath
if (!filePath) {
logger.error(
`Import file ${colors.magenta(importPath)} can not be resolved`
)
return {
importFilePath: null,
importCode: 'Error when resolving path',
Expand All @@ -25,6 +28,7 @@ export const resolveImportCode = (

// check file existence
if (!fs.existsSync(importFilePath)) {
logger.error(`Import file ${colors.magenta(importPath)} not found`)
return {
importFilePath,
importCode: 'File not found',
Expand Down