Skip to content

Commit

Permalink
fix(core): infer packages from workspaces.packages properly (#9686)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Apr 5, 2022
1 parent ef03d7c commit 05358ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/nx/src/config/workspaces.ts
Expand Up @@ -21,6 +21,7 @@ import {
TaskGraphExecutor,
Generator,
} from './misc-interfaces';
import { PackageJson } from '../utils/package-json';

export function workspaceConfigName(root: string) {
if (existsSync(path.join(root, 'angular.json'))) {
Expand Down Expand Up @@ -471,10 +472,14 @@ function getGlobPatternsFromPlugins(nxJson: NxJsonConfiguration): string[] {
function getGlobPatternsFromPackageManagerWorkspaces(root: string): string[] {
// TODO: add support for pnpm
try {
const { workspaces } = readJsonFile(join(root, 'package.json'));

const { workspaces } = readJsonFile<PackageJson>(
join(root, 'package.json')
);
const packages = Array.isArray(workspaces)
? workspaces
: workspaces?.packages;
return (
workspaces?.map((pattern) => pattern + '/package.json') ?? [
packages?.map((pattern) => pattern + '/package.json') ?? [
'**/package.json',
]
);
Expand Down
5 changes: 5 additions & 0 deletions packages/nx/src/utils/package-json.ts
Expand Up @@ -16,6 +16,11 @@ export interface PackageJson {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
workspaces?:
| string[]
| {
packages: string[];
};

// Nx Project Configuration
nx?: NxProjectPackageJsonConfiguration;
Expand Down

0 comments on commit 05358ae

Please sign in to comment.