Skip to content

Commit 48f0190

Browse files
committed
fix(watchPatternLabFiles): Register and manager watchers
1 parent 12ccbd7 commit 48f0190

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/lib/watchPatternLabFiles.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,18 @@ const watchPatternLabFiles = (
7474
_.each(patternWatches, patternWatchPath => {
7575
logger.debug(`Pattern Lab is watching ${patternWatchPath} for changes`);
7676

77+
if (patternlab.watchers[patternWatchPath]) {
78+
patternlab.watchers[patternWatchPath].close();
79+
}
80+
7781
const patternWatcher = chokidar.watch(path.resolve(patternWatchPath), {
7882
ignored: /(^|[\/\\])\../,
7983
ignoreInitial: true,
8084
awaitWriteFinish: {
8185
stabilityThreshold: 200,
8286
pollInterval: 100,
8387
},
88+
persistent: !watchOnce,
8489
});
8590

8691
//watch for changes and rebuild
@@ -100,13 +105,16 @@ const watchPatternLabFiles = (
100105
file: p,
101106
});
102107
});
108+
109+
patternlab.watchers[patternWatchPath] = patternWatcher;
103110
});
104111

105112
logger.info(
106113
`Pattern Lab is watching for changes to files under ${
107114
assetDirectories.source.root
108115
}`
109116
);
117+
return Promise.resolve();
110118
};
111119

112120
module.exports = watchPatternLabFiles;

0 commit comments

Comments
 (0)