Fix async filtering (#3008)
Summary: I relied too much on the types which in this case don't help at all. Filtering on a promise will just automatically get all values to pass. Pull Request resolved: https://github.com/facebook/flipper/pull/3008 Test Plan: `yarn build --mac` works again on the GH checkout. Reviewed By: mweststrate Differential Revision: D31991576 Pulled By: passy fbshipit-source-id: f632d29ddfc09b7130b68b4b17264fd30e1969ce
This commit is contained in:
committed by
Facebook GitHub Bot
parent
366c8f2681
commit
f8117240af
@@ -10,6 +10,7 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {homedir} from 'os';
|
import {homedir} from 'os';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
import pFilter from 'p-filter';
|
||||||
import expandTilde from 'expand-tilde';
|
import expandTilde from 'expand-tilde';
|
||||||
|
|
||||||
const flipperDataDir = path.join(homedir(), '.flipper');
|
const flipperDataDir = path.join(homedir(), '.flipper');
|
||||||
@@ -43,7 +44,7 @@ export async function getPluginSourceFolders(): Promise<string[]> {
|
|||||||
}
|
}
|
||||||
pluginFolders.push(path.resolve(__dirname, '..', '..', 'plugins', 'public'));
|
pluginFolders.push(path.resolve(__dirname, '..', '..', 'plugins', 'public'));
|
||||||
pluginFolders.push(path.resolve(__dirname, '..', '..', 'plugins', 'fb'));
|
pluginFolders.push(path.resolve(__dirname, '..', '..', 'plugins', 'fb'));
|
||||||
return pluginFolders.map(expandTilde).filter(async (f) => fs.pathExists(f));
|
return pFilter(pluginFolders.map(expandTilde), (p) => fs.pathExists(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPluginInstallationDir(name: string) {
|
export function getPluginInstallationDir(name: string) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
import pFilter from 'p-filter';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {getWatchFolders} from 'flipper-pkg-lib';
|
import {getWatchFolders} from 'flipper-pkg-lib';
|
||||||
import {appDir, publicPluginsDir, fbPluginsDir} from './paths';
|
import {appDir, publicPluginsDir, fbPluginsDir} from './paths';
|
||||||
@@ -29,7 +30,8 @@ export default async function getAppWatchFolders() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
|
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
|
||||||
return watchFolders
|
return pFilter(
|
||||||
.filter((value, index, self) => self.indexOf(value) === index)
|
watchFolders.filter((value, index, self) => self.indexOf(value) === index),
|
||||||
.filter(async (f) => fs.pathExists(f));
|
(f) => fs.pathExists(f),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user