From a6599963ec032a6f3c1738568034af4e4ca9b0e3 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 11 Jan 2021 10:49:13 -0800 Subject: [PATCH] Fix the issue with plugin installation from npm Summary: https://github.com/facebook/flipper/issues/1818 Reviewed By: jknoxville Differential Revision: D25870562 fbshipit-source-id: 0d62626355b35505089990cfdb592b0ea4b84fda --- desktop/plugin-lib/src/__tests__/pluginInstaller.node.ts | 6 ++++++ desktop/plugin-lib/src/pluginInstaller.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/desktop/plugin-lib/src/__tests__/pluginInstaller.node.ts b/desktop/plugin-lib/src/__tests__/pluginInstaller.node.ts index 5d239dacf..59fd8b50b 100644 --- a/desktop/plugin-lib/src/__tests__/pluginInstaller.node.ts +++ b/desktop/plugin-lib/src/__tests__/pluginInstaller.node.ts @@ -147,6 +147,12 @@ describe('pluginInstaller', () => { ]); }); + test('getInstalledPlugins when no plugins installed', async () => { + await fs.remove(pluginInstallationDir); + const plugins = await getInstalledPlugins(); + expect(plugins).toHaveLength(0); + }); + test('moveInstalledPluginsFromLegacyDir', async () => { await moveInstalledPluginsFromLegacyDir(); expect( diff --git a/desktop/plugin-lib/src/pluginInstaller.ts b/desktop/plugin-lib/src/pluginInstaller.ts index 11ce2ec95..e3a214c46 100644 --- a/desktop/plugin-lib/src/pluginInstaller.ts +++ b/desktop/plugin-lib/src/pluginInstaller.ts @@ -215,6 +215,9 @@ type InstalledPluginVersionDirs = [string, string[]][]; async function getInstalledPluginVersionDirs(): Promise< InstalledPluginVersionDirs > { + if (!(await fs.pathExists(pluginInstallationDir))) { + return []; + } return await fs .readdir(pluginInstallationDir) .then((dirs) => dirs.map((dir) => path.join(pluginInstallationDir, dir)))