Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worn if tmp is dot #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions air_example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ main = "magenta"
watcher = "cyan"
build = "yellow"
runner = "green"
warning = "red"

[misc]
# Delete tmp directory on exit
Expand Down
3 changes: 3 additions & 0 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type cfgColor struct {
Build string `toml:"build"`
Runner string `toml:"runner"`
App string `toml:"app"`
Warning string `toml:"warning"`
}

type cfgMisc struct {
Expand Down Expand Up @@ -104,6 +105,7 @@ func defaultConfig() config {
Watcher: "cyan",
Build: "yellow",
Runner: "green",
Warning: "red",
}
misc := cfgMisc{
CleanOnExit: false,
Expand Down Expand Up @@ -168,6 +170,7 @@ func (c *config) colorInfo() map[string]string {
"build": c.Color.Build,
"runner": c.Color.Runner,
"watcher": c.Color.Watcher,
"warning": c.Color.Warning,
}
}

Expand Down
3 changes: 3 additions & 0 deletions runner/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (e *Engine) Run() {

func (e *Engine) checkRunEnv() error {
p := e.config.tmpPath()
if p == "." {
e.warningLog("Your temp dir is '.', please notice, that it's gonna be wiped")
}
if _, err := os.Stat(p); os.IsNotExist(err) {
e.runnerLog("mkdir %s", p)
if err := os.Mkdir(p, 0755); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions runner/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func (l *logger) watcher() logFunc {
return l.getLogger("watcher")
}

func (l *logger) warning() logFunc {
return l.getLogger("warning")
}

func rawLogger() logFunc {
return newLogFunc("raw", defaultConfig().Log)
}
Expand Down
6 changes: 6 additions & 0 deletions runner/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func (e *Engine) watcherDebug(format string, v ...interface{}) {
}
}

func (e *Engine) warningLog(format string, v ...interface{}) {
e.logWithLock(func() {
e.logger.warning()(format, v...)
})
}

func (e *Engine) isTmpDir(path string) bool {
return path == e.config.tmpPath()
}
Expand Down