MCPcopy
hub / github.com/streamich/git-cz / getPackageDirectories

Function getPackageDirectories

lib/util/lerna.js:22–50  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

20const removeLastDirectoryPartOf = (url) => url.substring(0, url.lastIndexOf('/'));
21
22const 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
52const getAllPackages = (state) => {
53 try {

Callers 2

getAllPackagesFunction · 0.85
getChangedPackagesFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…