(state)
| 20 | const removeLastDirectoryPartOf = (url) => url.substring(0, url.lastIndexOf('/')); |
| 21 | |
| 22 | const getPackageDirectories = (state) => { |
| 23 | const pkgFilename = path.join(state.root, 'package.json'); |
| 24 | |
| 25 | if (fs.existsSync(pkgFilename)) { |
| 26 | try { |
| 27 | const workspacesConfig = require(String(pkgFilename)).workspaces; |
| 28 | const workspacePackages = Array.isArray(workspacesConfig) ? workspacesConfig : workspacesConfig.packages; |
| 29 | |
| 30 | if (workspacePackages && workspacePackages.length) { |
| 31 | return workspacePackages |
| 32 | .filter((workspacePackage) => workspacePackage.endsWith('*')) |
| 33 | .map((workspacePackage) => |
| 34 | removeLastDirectoryPartOf(String(workspacePackage)) |
| 35 | |
| 36 | // else { |
| 37 | // TODO: support paths that do not end with '*', in that case the package it self is the directory so we don't need to look at inner directories |
| 38 | // return workspacePackage |
| 39 | // } |
| 40 | ); |
| 41 | |
| 42 | // Remove the /* on the tail |
| 43 | } |
| 44 | // eslint-disable-next-line no-empty |
| 45 | } catch (error) { |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return 'packages'; |
| 50 | }; |
| 51 | |
| 52 | const getAllPackages = (state) => { |
| 53 | try { |
no test coverage detected
searching dependent graphs…