Download

Beta

Docs Blog Workflows Styles
GitHub

Native Methods
2 min

Learn how to interact with native modules and methods in a workflow.

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.

The native global

Any 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.ts
import { const Workflow: new (options: WorkflowOptions) => void
Construct a new workflow runner
Workflow
} from "relagit:actions";
export default new new Workflow(options: WorkflowOptions): voidWorkflow({ WorkflowOptions.name: stringname: "My Workflow", WorkflowOptions.description?: string | undefineddescription: "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; } | undefinedhooks: { commit?: ((event: "commit", params_0: Repository, params_1: { message: string; description: string; }) => void | Promise<void>) | undefinedcommit() { const native: { someMethod: () => Promise<void>; }native.someMethod: () => Promise<void>someMethod(); }, }, });

TypeScript support

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.ts
import * as import _native_native from "src/native.ts"; declare global { const const native: anynative: typeof import _native_native; }

Tip

There is another global value defined by RelaGit, options, but you will hear more about that in the options section.