api-extractor: check whether folder has a package.json
Often when switching between branches, I have empty folders in my working copy and Git doesn't track folders. Another case is the now deleted `core` package which remains as an empty folder locally (due to the node_modules folder still being there). Sadly, api-extractor crashes on empty folder, so this introduces a check that the folder is a package by checking for the package.json file. Signed-off-by: Oliver Sand <oliver.sand@sda-se.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
resolve as resolvePath,
|
||||
relative as relativePath,
|
||||
dirname,
|
||||
join,
|
||||
} from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import {
|
||||
@@ -96,6 +97,13 @@ async function findPackageDirs() {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const packageJsonPath = join(fullPackageDir, 'package.json');
|
||||
await fs.access(packageJsonPath);
|
||||
} catch (_) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const packageDir = relativePath(projectRoot, fullPackageDir);
|
||||
if (!SKIPPED_PACKAGES.includes(packageDir)) {
|
||||
packageDirs.push(packageDir);
|
||||
|
||||
Reference in New Issue
Block a user