JS API Reference

Class: WorkContext

task/work.WorkContext

Work Context

Description

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WorkContext(activity, options?): WorkContext

Parameters

NameType
activityActivity
options?WorkOptions

Returns

WorkContext

Defined in

src/task/work.ts:59

Properties

provider

Readonly provider: ProviderInfo

Defined in

src/task/work.ts:52


activity

Readonly activity: Activity

Defined in

src/task/work.ts:60

Methods

before

before(): Promise<void | Result<any>[]>

Returns

Promise<void | Result<any>[]>

Defined in

src/task/work.ts:70


run

run(commandLine, options?): Promise<Result<any>>

Execute a command on provider using a shell (/bin/sh).

Parameters

NameTypeDescription
commandLinestringShell command to execute.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:167

run(executable, args, options?): Promise<Result<any>>

Execute an executable on provider.

Parameters

NameTypeDescription
executablestringExecutable to run.
argsstring[]Executable arguments.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:176


spawn

spawn(commandLine, options?): Promise<RemoteProcess>

Spawn an executable on provider and return RemoteProcess object that contain stdout and stderr as Readable

Parameters

NameTypeDescription
commandLinestringShell command to execute.
options?Omit<CommandOptions, "capture">Additional run options.

Returns

Promise<RemoteProcess>

Defined in

src/task/work.ts:200

spawn(executable, args, options?): Promise<RemoteProcess>

Parameters

NameTypeDescription
executablestringExecutable to run.
argsstring[]Executable arguments.
options?CommandOptionsAdditional run options.

Returns

Promise<RemoteProcess>

Defined in

src/task/work.ts:206


transfer

transfer(from, to, options?): Promise<Result<any>>

Generic transfer command, requires the user to provide a publicly readable transfer source

Parameters

NameTypeDescription
fromstringpublicly available resource for reading. Supported protocols: file, http, ftp or gftp
tostringfile path
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:247


uploadFile

uploadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:252


uploadJson

uploadJson(json, dst, options?): Promise<Result<any>>

Parameters

NameType
jsonany
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:258


uploadData

uploadData(data, dst, options?): Promise<Result<any>>

Parameters

NameType
dataUint8Array
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:264


downloadFile

downloadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:269


downloadData

downloadData(src, options?): Promise<Result<Uint8Array>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<Uint8Array>>

Defined in

src/task/work.ts:274


downloadJson

downloadJson(src, options?): Promise<Result<any>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:280


beginBatch

beginBatch(): Batch

Returns

Batch

Defined in

src/task/work.ts:296


getWebsocketUri

getWebsocketUri(port): string

Parameters

NameType
portnumber

Returns

string

Defined in

src/task/work.ts:300


getIp

getIp(): string

Returns

string

Defined in

src/task/work.ts:312


getState

getState(): Promise<ActivityStateEnum>

Returns

Promise<ActivityStateEnum>

Defined in

src/task/work.ts:324

Was this helpful?