cameronhunter / jest-watch-directories

Jest watch plugins to filter to directories, lerna packages, or yarn workspaces
26 stars 0 forks source link

jest-watch-yarn-workspaces: Support new structure of the "workspaces" property #1

Closed busybeaver closed 5 years ago

busybeaver commented 5 years ago

Hi,

starting from yarn 1.4.2, the workspaces property in the package.json file can have a different structure (if the nohoist feature should be used; see details here):

"workspaces": {
  "packages": ["packages/*"],
  "nohoist": ["**/react-native", "**/react-native/**"]
}

While the old structure of just being an array is still valid, I suggest to support both formats in jest-watch-yarn-workspaces. See also the type definitions for workspaces property: [1,2].

From my understanding, this line would need some changes... maybe something like:

function getDirectories(packageConfig) {
  const yarnWorkspaces = packageConfig.workspaces;
  if (Array.isArray(yarnWorkspaces)) return yarnWorkspaces;
  if (yarnWorkspaces && Array.isArray(yarnWorkspaces.packages)) return yarnWorkspaces.packages;
  return undefined;
}
cameronhunter commented 5 years ago

Published as v1.1.0