A RelaGit workflow normally runs in a sandboxed environment in electron’s renderer process. This means that you can’t use node modules like fs
or path
in your workflow.
native
globalAny methods or variables you export from your native module will be available in your main workflow script via the native
global value.
RelaGit automatically loads your native module when it runs your workflow, so you don’t need to worry about importing it. Simply use native.methodName
to call your method.
index.tsimport {
const Workflow: new (options: WorkflowOptions) => void
Construct a new workflow runnerWorkflow } from "relagit:actions"; export default newnew Workflow(options: WorkflowOptions): void
Workflow({WorkflowOptions.name: string
name: "My Workflow",WorkflowOptions.description?: string | undefined
description: "A workflow that does something.",WorkflowOptions.hooks?: { navigate?: ((event: "navigate", params_0: Repository | undefined, params_1: GitFile | undefined) => void | Promise<void>) | undefined; ... 9 more ...; stash_pop?: ((event: "stash_pop", params_0: Repository) => void | Promise<...>) | undefined; } | undefined
hooks: {commit?: ((event: "commit", params_0: Repository, params_1: { message: string; description: string; }) => void | Promise<void>) | undefined
commit() {const native: { someMethod: () => Promise<void>; }
native.someMethod: () => Promise<void>
someMethod(); }, }, });
As we recommend using TypeScript for your workflows, you can also define the types for your native methods alongside the official types in the relagit
package.
native.d.tsimport * as
import _native
_native from "src/native.ts"; declare global { constconst native: any
native: typeofimport _native
_native; }
Tip
There is another global value defined by RelaGit, options
, but you will hear more about that in the options section.