Skip to content

Commit

Permalink
fix nim check nimscript [backport: 1.6] (#19444)
Browse files Browse the repository at this point in the history
fix #19440; fix #3858

(cherry picked from commit 7c3c61f)
  • Loading branch information
ringabout authored and narimiran committed Mar 24, 2022
1 parent 9df55a8 commit b741f3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,8 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser;
else:
if pass == passCmd1: config.commandArgs.add p.key
if argsCount == 1:
if p.key.endsWith(".nims"):
incl(config.globalOptions, optWasNimscript)
# support UNIX style filenames everywhere for portable build scripts:
if config.projectName.len == 0:
config.projectName = unixToNativePath(p.key)
Expand Down
6 changes: 5 additions & 1 deletion compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ proc commandCheck(graph: ModuleGraph) =
let conf = graph.config
conf.setErrorMaxHighMaybe
defineSymbol(conf.symbols, "nimcheck")
if optWasNimscript in conf.globalOptions:
defineSymbol(conf.symbols, "nimscript")
defineSymbol(conf.symbols, "nimconfig")
semanticPasses(graph) # use an empty backend for semantic checking only
compileProject(graph)

Expand Down Expand Up @@ -363,7 +366,8 @@ proc mainCommand*(graph: ModuleGraph) =
msgWriteln(conf, "-- end of list --", {msgStdout, msgSkipHook})

for it in conf.searchPaths: msgWriteln(conf, it.string)
of cmdCheck: commandCheck(graph)
of cmdCheck:
commandCheck(graph)
of cmdParse:
wantMainModule(conf)
discard parseFile(conf.projectMainIdx, cache, conf)
Expand Down
11 changes: 11 additions & 0 deletions tests/newconfig/tconfigcheck.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
discard """
cmd: "nim check $file"
"""

mode = ScriptMode.Verbose
proc build() =
echo "building nim... "
exec "sleep 10"
echo getCurrentDir()

echo "hello"

0 comments on commit b741f3c

Please sign in to comment.