Skip to content

Commit

Permalink
feat(markdown): add error log for importCode plugin (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Feb 27, 2023
1 parent e9b35cf commit b722a62
Showing 1 changed file with 5 additions and 1 deletion.
@@ -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

0 comments on commit b722a62

Please sign in to comment.