Structure
JSScriptRunner
Runs a named script from package.json using the detected package manager.
struct JSScriptRunnerOverview
Validates that the script exists before invoking the package manager. Automatically installs dependencies when node_modules is absent.
Usage
let runner = JSScriptRunner(context: context.shell, projectRoot: ".")
let output = try await runner.run(script: "test")Topics
Initializers
init(context: ShellContext, projectRoot: String, fileManager: FileManager)Creates a
JSScriptRunnerusing the auto-detected package manager.init(context: ShellContext, projectRoot: String, packageManager: JSPackageManager)Creates a
JSScriptRunnerwith an explicit package manager (for testing).
Instance Properties
var resolvedPackageManager: JSPackageManagerThe resolved package manager for this runner.
Instance Methods
func run(script: String, arguments: [String]) async throws -> ShellOutputRuns a named script from
package.json.func scriptUsesJest(String) -> BoolWhether the named package script invokes Jest and accepts Jest’s JSON output flags.
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype