mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Chore: gracefully handle empty folders on dev machines
This commit is contained in:
parent
e33f6714c6
commit
55d22d69f8
@ -5,7 +5,7 @@ import * as process from 'node:process';
|
||||
import { globalExternals } from '@fal-works/esbuild-plugin-global-externals';
|
||||
import { spawn } from 'cross-spawn';
|
||||
import * as esbuild from 'esbuild';
|
||||
import { readJson } from 'fs-extra';
|
||||
import { pathExists, readJson } from 'fs-extra';
|
||||
import { glob } from 'glob';
|
||||
import limit from 'p-limit';
|
||||
import picocolors from 'picocolors';
|
||||
@ -129,10 +129,19 @@ export const getWorkspace = async () => {
|
||||
return Promise.all(
|
||||
workspaces
|
||||
.flatMap((p) => p.map((i) => join(CODE_DIRECTORY, i)))
|
||||
.map(async (p) => {
|
||||
const pkg = await readJson(join(p, 'package.json'));
|
||||
return { ...pkg, path: p } as typefest.PackageJson &
|
||||
.map(async (packagePath) => {
|
||||
const packageJsonPath = join(packagePath, 'package.json');
|
||||
if (!(await pathExists(packageJsonPath))) {
|
||||
// If we delete a package, then an empty folder might still be left behind on some dev machines
|
||||
// In this case, just ignore the folder
|
||||
console.warn(
|
||||
`No package.json found in ${packagePath}. You might want to delete this folder.`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const pkg = await readJson(packageJsonPath);
|
||||
return { ...pkg, path: packagePath } as typefest.PackageJson &
|
||||
Required<Pick<typefest.PackageJson, 'name' | 'version'>> & { path: string };
|
||||
})
|
||||
);
|
||||
).then((packages) => packages.filter((p) => p !== null));
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user