Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/vx/src/cli/why.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ async function resolveTarget(
if (matches.length > 1) {
throw ambiguousTask('why', target, matches)
}
// Asked outside the one project declaring it, a group read as a task
// that never ran, pointed at `vx last --stats`.
const kind = await declared()
if (kind === 'group' || kind === 'no-op task') throw groupRefusal(target, kind)
}
const ids = new LocalHistoryProvider(db).recentTaskIds()
const invoked = ids.length === 0 && db.query('SELECT 1 FROM invocations LIMIT 1').get() !== null
Expand Down
3 changes: 3 additions & 0 deletions packages/vx/tests/why.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,9 @@ describe('vx why of a declared task that never ran', () => {
for (const [cwd, target, id] of [
[app, 'all', 'app#all'],
[root, 'app#all', 'app#all'],
// Bare from the root it read "no recorded runs for task", as if it
// could have run.
[root, 'all', 'all'],
] as const) {
const r = await vx(cwd, ['why', target])
expect({ code: r.code, err: r.err }).toEqual({
Expand Down
Loading