detect

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package detect finds the coverage collection targets under a directory: Go modules (a go.mod file) and Node packages (a package.json file).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind string

Kind identifies the ecosystem of a detected project.

const (
	KindGo   Kind = "go"
	KindNode Kind = "node"
)

type Project

type Project struct {
	// Dir is the absolute directory holding the manifest.
	Dir string
	// Rel is Dir relative to the scan root, slash-separated; "." for the root
	// itself.
	Rel  string
	Kind Kind

	// Go module path, read from the go.mod module directive.
	ModulePath string

	// Node package metadata.
	PackageName   string
	TestScript    string
	HasTestScript bool
	// Runner is "vitest", "jest" or "" when no known runner could be inferred.
	Runner string
	// HasNodeModules reports whether a node_modules directory sits beside the
	// manifest, which determines whether a local runner binary can be used.
	HasNodeModules bool
}

Project is one coverage collection target.

type Result

type Result struct {
	Root     string
	Projects []Project
	// HasTypeScript and HasJavaScript record whether the tree contains files of
	// those kinds at all, independent of whether any of them are runnable.
	HasTypeScript bool
	HasJavaScript bool
}

Result is the outcome of a scan.

func Scan

func Scan(root string) (*Result, error)

Scan walks root and returns every Go module and Node package it finds.

Hidden directories are skipped (which covers .git, .cover100 and editor state), as are node_modules and vendor. Unreadable subtrees are skipped rather than failing the scan: a permission error deep in a tree should not prevent collecting coverage from everything else.

func (*Result) GoModules

func (r *Result) GoModules() []Project

GoModules returns the detected Go projects.

func (*Result) NodePackages

func (r *Result) NodePackages() []Project

NodePackages returns the detected Node projects that declare a test script.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL