From bc69f3594823516b662ce5f54f3ee589e264975d Mon Sep 17 00:00:00 2001 From: David Vogel Date: Mon, 3 Nov 2025 21:44:01 +0100 Subject: [PATCH] Allow it to compile on unsupported platforms --- cli.go | 6 ++++++ cli_js.go | 12 ++++++++++++ cli_wasi.go | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 cli_js.go create mode 100644 cli_wasi.go diff --git a/cli.go b/cli.go index 89afadb..36aefa9 100644 --- a/cli.go +++ b/cli.go @@ -30,6 +30,9 @@ func (c CLI) VersionString() (string, error) { if c.ExecutablePath != "" { execPath = c.ExecutablePath } + if execPath == "" { + return "", fmt.Errorf("go-typst doesn't support this platform") + } cmd := exec.Command(execPath, "--version") cmd.Dir = c.WorkingDirectory // This doesn't do anything, but we will do it anyways for consistency. @@ -64,6 +67,9 @@ func (c CLI) Compile(input io.Reader, output io.Writer, options *CLIOptions) err if c.ExecutablePath != "" { execPath = c.ExecutablePath } + if execPath == "" { + return fmt.Errorf("go-typst doesn't support this platform") + } cmd := exec.Command(execPath, args...) cmd.Dir = c.WorkingDirectory diff --git a/cli_js.go b/cli_js.go new file mode 100644 index 0000000..6080ea2 --- /dev/null +++ b/cli_js.go @@ -0,0 +1,12 @@ +// Copyright (c) 2025 David Vogel +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +//go:build js + +package typst + +// The path to the Typst executable. +// We leave that empty as we don't support this platform for now. +var ExecutablePath = "" diff --git a/cli_wasi.go b/cli_wasi.go new file mode 100644 index 0000000..87b7c55 --- /dev/null +++ b/cli_wasi.go @@ -0,0 +1,12 @@ +// Copyright (c) 2025 David Vogel +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +//go:build wasip1 + +package typst + +// The path to the Typst executable. +// We leave that empty as we don't support this platform for now. +var ExecutablePath = ""