Skip to content

Commit 6f4a3dc

Browse files
Copilotvoxpelli
andcommitted
Add debug logging for parent workspace detection
- Log when attempting to resolve parent workspace root - Log whether a parent workspace was found and its path - Log when parent workspace detection is skipped and why - Fix parentWorkspace flag to work correctly with --no- prefix (changed from noParentWorkspace:false to parentWorkspace:true) Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
1 parent 24cf5cc commit 6f4a3dc

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

cli.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const cli = meow(`
5656
ignore: { shortFlag: 'i', type: 'string', isMultiple: true },
5757
ignoreDev: { shortFlag: 'd', type: 'boolean' },
5858
includeWorkspaceRoot: { type: 'boolean', 'default': true },
59-
noParentWorkspace: { type: 'boolean', 'default': false },
59+
parentWorkspace: { type: 'boolean', 'default': true },
6060
peerCheck: { shortFlag: 'p', type: 'boolean' },
6161
strict: { shortFlag: 's', type: 'boolean' },
6262
verbose: { shortFlag: 'v', type: 'boolean' },
@@ -80,7 +80,7 @@ const {
8080
engineNoDev, // deprecated
8181
fix = false,
8282
includeWorkspaceRoot,
83-
noParentWorkspace,
83+
parentWorkspace,
8484
peerCheck,
8585
strict,
8686
verbose,
@@ -123,9 +123,21 @@ let workspaceFilter = workspace;
123123
// - User hasn't explicitly opted out with --no-parent-workspace
124124
// - User hasn't provided explicit workspace filters (which would be incompatible)
125125
// - User hasn't provided a custom cwd path (cli.input[0])
126-
if (!noParentWorkspace && !workspace?.length && !cli.input[0]) {
126+
if (parentWorkspace && !workspace?.length && !cli.input[0]) {
127+
if (debug) {
128+
console.log(chalk.blue('Parent workspace detection:') + ' Attempting to resolve parent workspace root');
129+
}
130+
127131
const parentWorkspaceRoot = await resolveWorkspaceRootAsync(requestedCwd);
128132

133+
if (debug) {
134+
if (parentWorkspaceRoot) {
135+
console.log(chalk.blue('Parent workspace detection:') + ' Found parent workspace root: ' + parentWorkspaceRoot);
136+
} else {
137+
console.log(chalk.blue('Parent workspace detection:') + ' No parent workspace root found');
138+
}
139+
}
140+
129141
// If we found a parent workspace root different from our requested cwd,
130142
// we're in a workspace situation
131143
if (parentWorkspaceRoot && parentWorkspaceRoot !== requestedCwd) {
@@ -134,7 +146,19 @@ if (!noParentWorkspace && !workspace?.length && !cli.input[0]) {
134146

135147
// Filter to just the current workspace to avoid checking all workspaces in the parent monorepo
136148
workspaceFilter = [requestedCwd];
149+
150+
if (debug) {
151+
console.log(chalk.blue('Parent workspace detection:') + ' Using parent workspace root, filtering to current workspace');
152+
}
153+
} else if (debug && parentWorkspaceRoot === requestedCwd) {
154+
console.log(chalk.blue('Parent workspace detection:') + ' Parent workspace root is same as requested cwd, not applying');
137155
}
156+
} else if (debug) {
157+
const reasons = [];
158+
if (!parentWorkspace) reasons.push('--no-parent-workspace flag is set');
159+
if (workspace?.length) reasons.push('explicit workspace filters provided');
160+
if (cli.input[0]) reasons.push('custom cwd path provided');
161+
console.log(chalk.blue('Parent workspace detection:') + ' Skipped (' + reasons.join(', ') + ')');
138162
}
139163

140164
/** @type {import('installed-check-core').LookupOptions} */

0 commit comments

Comments
 (0)