Skip to content

Commit

Permalink
Fix markdown watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoattal committed Nov 27, 2024
1 parent 77da6d3 commit 5fee478
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/histoire/src/node/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import MarkdownIt from 'markdown-it'
import anchor from 'markdown-it-anchor'
import attrs from 'markdown-it-attrs'
import { full as emoji } from 'markdown-it-emoji'
import micromatch from 'micromatch'
import path from 'pathe'
import pc from 'picocolors'
import { getHighlighter } from 'shiki-es'
Expand Down Expand Up @@ -137,9 +138,18 @@ export async function createMarkdownPlugins(ctx: Context) {
export async function createMarkdownFilesWatcher(ctx: Context) {
const md = await createMarkdownRendererWithPlugins(ctx)

const watcher = chokidar.watch(['**/*.story.md'], {
const watcher = chokidar.watch('.', {
cwd: ctx.root,
ignored: ctx.config.storyIgnored,
ignored: (path, stats) => {
if (ctx.config.storyIgnored.some(pattern => micromatch.isMatch(path, pattern))) {
return true
}
if (micromatch.isMatch(path, '**/*.story.md')) {
return false
}

return stats?.isFile()
},
})

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/histoire/src/node/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function watchStories(newContext: Context) {
context = newContext

const watcher = chokidar.watch('.', {
cwd: context.root,
ignored: (path, stats) => {
if (context.config.storyIgnored.some(pattern => micromatch.isMatch(path, pattern))) {
return true
Expand All @@ -56,7 +57,6 @@ export async function watchStories(newContext: Context) {

return stats?.isFile()
},
cwd: context.root,
})

watcher
Expand Down

0 comments on commit 5fee478

Please sign in to comment.