Skip to content

Commit

Permalink
fix: running external tools only on insert commands
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Jan 4, 2024
1 parent 96fa073 commit 38c9677
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/plugins/externalTool.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
## Copyright (c) 2023, Crash Override, Inc.
## Copyright (c) 2023-2024, Crash Override, Inc.
##
## This file is part of Chalk
## (see https://crashoverride.com/docs/chalk)
Expand Down Expand Up @@ -98,15 +98,19 @@ template toolBase(s: untyped) {.dirty.} =

var
toolInfo: Table[string, seq[(int, PIInfo)]]
dict: ChalkDict = ChalkDict()
let
runSbom = chalkConfig.getRunSbomTools()
runSast = chalkConfig.getRunSastTools()

# tools should only run during insert operations
if getCommandName() notin @["build", "insert"]:
return result

for k, v in chalkConfig.tools:
if not v.enabled: continue
if not runSbom and v.kind == "sbom": continue
if not runSast and v.kind == "sast": continue

let priority = v.priority
if v.kind notin toolInfo:
toolInfo[v.kind] = @[(priority, PIInfo(name: k, obj: v))]
Expand All @@ -118,9 +122,7 @@ template toolBase(s: untyped) {.dirty.} =
sortArr.sort()
for (ignore, info) in sortArr:
trace("Running tool: " & info.name)
if info.runOneTool(resolvePath(s), dict): break

return dict
if info.runOneTool(resolvePath(s), result): break

proc toolGetChalkTimeHostInfo*(self: Plugin): ChalkDict {.cdecl.} =
toolBase(getContextDirectories()[0])
Expand Down

0 comments on commit 38c9677

Please sign in to comment.