Flipper does not reload plugin when source code is modified in a custom folder (#783)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/783 https://github.com/facebook/flipper/issues/756 Reviewed By: mweststrate Differential Revision: D19788859 fbshipit-source-id: 524ea36fc72ae84b68cda7922a74bbbbfe06663f
This commit is contained in:
committed by
Facebook Github Bot
parent
c52ca255bb
commit
c62127e56a
@@ -53,19 +53,30 @@ module.exports = async (
|
||||
};
|
||||
|
||||
async function startWatchingPluginsUsingWatchman(plugins, onPluginChanged) {
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
const watchman = new Watchman(rootDir);
|
||||
await watchman.initialize();
|
||||
// Initializing a watchman for each folder containing plugins
|
||||
const watchmanRootMap = {};
|
||||
await Promise.all(
|
||||
plugins.map(plugin =>
|
||||
watchman.startWatchFiles(
|
||||
path.relative(rootDir, plugin.rootDir),
|
||||
plugins.map(async plugin => {
|
||||
const watchmanRoot = path.resolve(plugin.rootDir, '..');
|
||||
if (!watchmanRootMap[watchmanRoot]) {
|
||||
watchmanRootMap[watchmanRoot] = new Watchman(watchmanRoot);
|
||||
await watchmanRootMap[watchmanRoot].initialize();
|
||||
}
|
||||
}),
|
||||
);
|
||||
// Start watching plugins using the initialized watchmans
|
||||
await Promise.all(
|
||||
plugins.map(async plugin => {
|
||||
const watchmanRoot = path.resolve(plugin.rootDir, '..');
|
||||
const watchman = watchmanRootMap[watchmanRoot];
|
||||
await watchman.startWatchFiles(
|
||||
path.relative(watchmanRoot, plugin.rootDir),
|
||||
() => onPluginChanged(plugin),
|
||||
{
|
||||
excludes: ['**/__tests__/**/*', '**/node_modules/**/*', '**/.*'],
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user