From 47349731bb41caeb9f1a06bd36eb99070cc0b1ac Mon Sep 17 00:00:00 2001 From: joeyak Date: Sat, 4 Nov 2023 15:12:03 -0400 Subject: [PATCH 1/2] Add skip_run so build only works on windows --- README.md | 4 +--- air_example.toml | 2 ++ runner/config.go | 1 + runner/engine.go | 8 ++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b82ce81f..2ed4e2f2 100644 --- a/README.md +++ b/README.md @@ -250,11 +250,9 @@ Should use `\` to escape the `' in the bin. related issue: [#305](https://github ### Question: how to do hot compile only and do not run anything? -[#365](https://github.com/cosmtrek/air/issues/365) - ```toml [build] - cmd = "/usr/bin/true" + skip_run = true ``` ## Development diff --git a/air_example.toml b/air_example.toml index 8540084f..0b8254b1 100644 --- a/air_example.toml +++ b/air_example.toml @@ -52,6 +52,8 @@ rerun = false rerun_delay = 500 # Add additional arguments when running binary (bin/full_bin). Will run './tmp/main hello world'. args_bin = ["hello", "world"] +# Skips the run step so it's only builds +skip_run = false [log] # Show log time diff --git a/runner/config.go b/runner/config.go index 10165365..46a1ffd5 100644 --- a/runner/config.go +++ b/runner/config.go @@ -57,6 +57,7 @@ type cfgBuild struct { KillDelay time.Duration `toml:"kill_delay"` Rerun bool `toml:"rerun"` RerunDelay int `toml:"rerun_delay"` + SkipRun bool `toml:"skip_run"` regexCompiled []*regexp.Regexp } diff --git a/runner/engine.go b/runner/engine.go index b30c9c2a..2669bddb 100644 --- a/runner/engine.go +++ b/runner/engine.go @@ -402,8 +402,12 @@ func (e *Engine) buildRun() { return default: } - if err = e.runBin(); err != nil { - e.runnerLog("failed to run, error: %s", err.Error()) + if e.config.Build.SkipRun { + e.runnerLog("skipping run step") + } else { + if err = e.runBin(); err != nil { + e.runnerLog("failed to run, error: %s", err.Error()) + } } } From 50b414365702d69ae058be518ddd167c1e936bac Mon Sep 17 00:00:00 2001 From: joeyak <27922090+joeyak@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:03:25 -0500 Subject: [PATCH 2/2] Fix added newline in merge conflict resolution --- runner/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runner/config.go b/runner/config.go index ccbacad3..26379c89 100644 --- a/runner/config.go +++ b/runner/config.go @@ -35,7 +35,6 @@ type Config struct { } type cfgBuild struct { - PreCmd []string `toml:"pre_cmd" usage:"Array of commands to run before each build"` Cmd string `toml:"cmd" usage:"Just plain old shell command. You could use 'make' as well"` PostCmd []string `toml:"post_cmd" usage:"Array of commands to run after ^C"` @@ -59,7 +58,7 @@ type cfgBuild struct { KillDelay time.Duration `toml:"kill_delay" usage:"Delay after sending Interrupt signal"` Rerun bool `toml:"rerun" usage:"Rerun binary or not"` RerunDelay int `toml:"rerun_delay" usage:"Delay after each execution"` - SkipRun bool `toml:"skip_run" usage:"Only build the application, do not run"` + SkipRun bool `toml:"skip_run" usage:"Only build the application, do not run"` regexCompiled []*regexp.Regexp }