Sitelet https://gro.fuz.dev/docs/api/task.ts#TaskContext

task.ts

view source

Declarations
#

22 declarations

find_tasks
#

task.ts view source

(input_paths: InputPath[], task_root_dirs: PathId[], config: GroConfig, timings?: Timings | undefined): Promise<FindTasksResult> import {find_tasks} from '@fuzdev/gro/task.js';

Finds modules from input paths. (see input_path.ts for more)

input_paths

type InputPath[]

task_root_dirs

type PathId[]

config

timings?

type Timings
optional

returns

Promise<FindTasksResult>

FindModulesFailure
#

task.ts view source

FindModulesFailure

type { type: "unmapped_input_paths"; unmapped_input_paths: InputPath[]; resolved_input_paths: ResolvedInputPath[]; input_paths: InputPath[]; task_root_dirs: PathId[]; reasons: string[]; } | { type: "input_directories_with_no_files"; input_directories_with_no_files: InputPath[]; resolved_input_files: ResolvedInputFile[]; resolved_input_files_by_root_dir: Map<PathId, ResolvedInputFile[]>; resolved_input_paths: ResolvedInputPath[]; input_paths: InputPath[]; task_root_dirs: PathId[]; reasons: string[]; }

import type {FindModulesFailure} from '@fuzdev/gro/task.js';

FindTasksResult
#

task.ts view source

FindTasksResult

type ({ ok: true; } & { value: FoundTasks; }) | (({ ok: false; } & { type: "unmapped_input_paths"; unmapped_input_paths: InputPath[]; resolved_input_paths: ResolvedInputPath[]; input_paths: InputPath[]; task_root_dirs: PathId[]; reasons: string[]; }) | ({ ok: false; } & { type: "input_directories_with_no_files"; input_directories_with_no_files: InputPath[]; resolved_input_files: ResolvedInputFile[]; resolved_input_files_by_root_dir: Map<PathId, ResolvedInputFile[]>; resolved_input_paths: ResolvedInputPath[]; input_paths: InputPath[]; task_root_dirs: PathId[]; reasons: string[]; }))

import type {FindTasksResult} from '@fuzdev/gro/task.js';

FoundTask
#

task.ts view source

FoundTask import type {FoundTask} from '@fuzdev/gro/task.js';

input_path

type InputPath

id

type PathId

task_root_dir

type PathId

FoundTasks
#

InvokeTask
#

task.ts view source

InvokeTask import type {InvokeTask} from '@fuzdev/gro/task.js';

(call)

type (task_name: string, args?: Args | undefined, config?: GroConfig | undefined): Promise<void>

task_name

type string

args?

type Args
optional

config?

optional
returns Promise<void>

is_task_path
#

task.ts view source

(path: string): boolean import {is_task_path} from '@fuzdev/gro/task.js';

path

type string

returns

boolean

load_tasks
#

task.ts view source

(found_tasks: FoundTasks, root_path?: PathId): Promise<LoadTasksResult> import {load_tasks} from '@fuzdev/gro/task.js';

found_tasks

root_path

type PathId
default process.cwd()

returns

Promise<LoadTasksResult>

LoadedTasks
#

LoadTasksFailure
#

LoadTasksResult
#

task.ts view source

LoadTasksResult

type ({ ok: true; } & { value: LoadedTasks; }) | ({ ok: false; } & LoadTasksFailure)

import type {LoadTasksResult} from '@fuzdev/gro/task.js';

SilentError
#

task.ts view source

import {SilentError} from '@fuzdev/gro/task.js';

This is used to tell Gro to exit silently, usually still with with a non-zero exit code. Using it means error logging is handled by the code that threw it.

inheritance

extends: Error

Task
#

task.ts view source

Task<TArgs, TArgsSchema, TReturn> import type {Task} from '@fuzdev/gro/task.js';

generics

Task<TArgs = Args, TArgsSchema extends z.ZodType<Args, Args> = z.ZodType<Args, Args>, TReturn = unknown>
TArgs
default Args
TArgsSchema
constraint z.ZodType<Args, Args>
default z.ZodType<Args, Args>
TReturn
default unknown

run

type (ctx: TaskContext<TArgs>): TReturn | Promise<TReturn>

ctx

type TaskContext<TArgs>
returns TReturn | Promise<TReturn>

summary?

type string

Args?

type TArgsSchema

TASK_FILE_SUFFIX_JS
#

TASK_FILE_SUFFIX_TS
#

TASK_FILE_SUFFIXES
#

TaskContext
#

task.ts view source

TaskContext<TArgs> import type {TaskContext} from '@fuzdev/gro/task.js';

generics

TaskContext<TArgs = object>
TArgs
default object

args

type TArgs

config

type GroConfig

svelte_config

Resolved on first access, so tasks that don't touch it never pay to read the SvelteKit config.

type Promise<ParsedSvelteConfig>

filer

type Filer

log

type Logger

timings

type Timings

invoke_task

type (task_name: string, args?: Args | undefined, config?: GroConfig | undefined): Promise<void>

task_name

type string

args?

type Args
optional

config?

optional
returns Promise<void>

TaskError
#

task.ts view source

import {TaskError} from '@fuzdev/gro/task.js';

This is used by tasks to signal a known failure. It's useful for cleaning up logging because we usually don't need their stack trace.

inheritance

extends: Error

TaskModule
#

task.ts view source

TaskModule import type {TaskModule} from '@fuzdev/gro/task.js';

task

type Task<Args, ZodType<Args, Args, $ZodTypeInternals<Args, Args>>, unknown>

TaskModuleMeta
#

task.ts view source

TaskModuleMeta import type {TaskModuleMeta} from '@fuzdev/gro/task.js';

inheritance

extends: ModuleMeta<TaskModule>

name

type string

to_task_name
#

task.ts view source

(id: PathId, task_root_dir: PathId, input_path: InputPath, root_path: PathId): string import {to_task_name} from '@fuzdev/gro/task.js';

id

type PathId

task_root_dir

type PathId

input_path

root_path

type PathId

returns

string

validate_task_module
#

task.ts view source

(mod: Record<string, any>): mod is TaskModule import {validate_task_module} from '@fuzdev/gro/task.js';

mod

type Record<string, any>

returns

boolean

Depends on
#

Imported by
#