From 52fa8271ecea6760992fcb8bf1edcd71d3934fb8 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 15 Jun 2017 11:56:13 +0300 Subject: [PATCH] fix: skip not found dir in getPkgDirs --- src/fs/getPkgDirs.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fs/getPkgDirs.ts b/src/fs/getPkgDirs.ts index cbbdb2d574..98b060a793 100644 --- a/src/fs/getPkgDirs.ts +++ b/src/fs/getPkgDirs.ts @@ -2,6 +2,7 @@ import fs = require('mz/fs') import path = require('path') import flatten = require('arr-flatten') import pFilter = require('p-filter') +import logger from 'pnpm-logger' export default async function (modules: string): Promise { const dirs = await getDirectories(modules) @@ -28,8 +29,14 @@ async function getDirectories (srcPath: string): Promise { .filter(relativePath => relativePath[0] !== '.') // ignore directories like .bin, .store, etc .map(relativePath => path.join(srcPath, relativePath)), async (absolutePath: string) => { - const stats = await fs.stat(absolutePath) - return stats.isDirectory() + try { + const stats = await fs.stat(absolutePath) + return stats.isDirectory() + } catch (err) { + if (err!.code !== 'ENOENT') throw err + logger.warn(`Cannot find file at ${absolutePath} although it was listed by readdir`) + return false + } } ) }