* fix #17190 * cah * merge * Update tnimscriptwithnimext.nim * Update tnimscriptwithmacro.nims * Apply suggestions from code review * Delete tnimscriptwithnimext.nim * Update tests/tools/tnimscriptwithmacro.nims * fix * fix * add a test * Apply suggestions from code review Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> * Apply suggestions from code review * Update changelog.md Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
parent
fe9a37f2a5
commit
924ab3adea
5 changed files with 18 additions and 4 deletions
|
|
@ -281,6 +281,8 @@
|
||||||
- Tuple expressions are now parsed consistently as
|
- Tuple expressions are now parsed consistently as
|
||||||
`nnkTupleConstr` node. Will affect macros expecting nodes to be of `nnkPar`.
|
`nnkTupleConstr` node. Will affect macros expecting nodes to be of `nnkPar`.
|
||||||
|
|
||||||
|
- `nim e` now accepts arbitrary file extensions for the nimscript file,
|
||||||
|
although `.nims` is still the preferred extension in general.
|
||||||
|
|
||||||
## Compiler changes
|
## Compiler changes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,8 +342,6 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
if conf.projectIsCmd or conf.projectIsStdin: discard
|
if conf.projectIsCmd or conf.projectIsStdin: discard
|
||||||
elif not fileExists(conf.projectFull):
|
elif not fileExists(conf.projectFull):
|
||||||
rawMessage(conf, errGenerated, "NimScript file does not exist: " & conf.projectFull.string)
|
rawMessage(conf, errGenerated, "NimScript file does not exist: " & conf.projectFull.string)
|
||||||
elif not conf.projectFull.string.endsWith(".nims"):
|
|
||||||
rawMessage(conf, errGenerated, "not a NimScript file: " & conf.projectFull.string)
|
|
||||||
# main NimScript logic handled in `loadConfigs`.
|
# main NimScript logic handled in `loadConfigs`.
|
||||||
of cmdNop: discard
|
of cmdNop: discard
|
||||||
of cmdJsonscript:
|
of cmdJsonscript:
|
||||||
|
|
|
||||||
|
|
@ -298,11 +298,14 @@ proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef; idgen:
|
||||||
for filename in configFiles:
|
for filename in configFiles:
|
||||||
# delayed to here so that `hintConf` is honored
|
# delayed to here so that `hintConf` is honored
|
||||||
rawMessage(conf, hintConf, filename.string)
|
rawMessage(conf, hintConf, filename.string)
|
||||||
if scriptIsProj:
|
if conf.cmd == cmdNimscript:
|
||||||
showHintConf()
|
showHintConf()
|
||||||
configFiles.setLen 0
|
configFiles.setLen 0
|
||||||
if conf.cmd != cmdIdeTools:
|
if conf.cmd != cmdIdeTools:
|
||||||
runNimScriptIfExists(scriptFile, isMain = true)
|
if conf.cmd == cmdNimscript:
|
||||||
|
runNimScriptIfExists(conf.projectFull, isMain = true)
|
||||||
|
else:
|
||||||
|
runNimScriptIfExists(scriptFile, isMain = true)
|
||||||
else:
|
else:
|
||||||
if not scriptIsProj:
|
if not scriptIsProj:
|
||||||
runNimScriptIfExists(scriptFile, isMain = true)
|
runNimScriptIfExists(scriptFile, isMain = true)
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,15 @@ tests/newconfig/bar/mfoo.nims""".splitLines
|
||||||
expected.add &"Hint: used config file '{b}' [Conf]\n"
|
expected.add &"Hint: used config file '{b}' [Conf]\n"
|
||||||
doAssert outp.endsWith expected, outp & "\n" & expected
|
doAssert outp.endsWith expected, outp & "\n" & expected
|
||||||
|
|
||||||
|
block: # mfoo2.customext
|
||||||
|
let filename = testsDir / "newconfig/foo2/mfoo2.customext"
|
||||||
|
let cmd = fmt"{nim} e --hint:conf {filename}"
|
||||||
|
let (outp, exitCode) = execCmdEx(cmd, options = {poStdErrToStdOut})
|
||||||
|
doAssert exitCode == 0
|
||||||
|
var expected = &"Hint: used config file '{filename}' [Conf]\n"
|
||||||
|
doAssert outp.endsWith "123" & "\n" & expected
|
||||||
|
|
||||||
|
|
||||||
block: # nim --eval
|
block: # nim --eval
|
||||||
let opt = "--hints:off"
|
let opt = "--hints:off"
|
||||||
check fmt"""{nim} {opt} --eval:"echo defined(nimscript)"""".execCmdEx == ("true\n", 0)
|
check fmt"""{nim} {opt} --eval:"echo defined(nimscript)"""".execCmdEx == ("true\n", 0)
|
||||||
|
|
|
||||||
2
tests/newconfig/foo2/mfoo2.customext
Normal file
2
tests/newconfig/foo2/mfoo2.customext
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
doAssert defined(nimscript)
|
||||||
|
echo "123"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue