mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
find the nodejs binary
upstream calls it node, debian calls it nodejs. We gotta look for both of them.
This commit is contained in:
@@ -15,7 +15,8 @@ when defined(gcc) and defined(windows):
|
||||
|
||||
import
|
||||
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
||||
extccomp, strutils, os, osproc, platform, main, parseopt, service
|
||||
extccomp, strutils, os, osproc, platform, main, parseopt, service,
|
||||
nodejs
|
||||
|
||||
when hasTinyCBackend:
|
||||
import tccgen
|
||||
@@ -67,7 +68,7 @@ proc handleCmdLine() =
|
||||
else:
|
||||
ex = quoteShell(
|
||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||
execExternalProgram("node " & ex & ' ' & commands.arguments)
|
||||
execExternalProgram(findNodeJs & " " & ex & ' ' & commands.arguments)
|
||||
else:
|
||||
var binPath: string
|
||||
if options.outFile.len > 0:
|
||||
|
||||
6
lib/core/nodejs.nim
Normal file
6
lib/core/nodejs.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
import os
|
||||
|
||||
proc findNodeJs*(): string =
|
||||
result = findExe("nodejs")
|
||||
if result == "":
|
||||
result = findExe("node")
|
||||
@@ -12,7 +12,7 @@
|
||||
import
|
||||
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
|
||||
marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
|
||||
algorithm
|
||||
algorithm, nodejs
|
||||
|
||||
const
|
||||
resultsFile = "testresults.html"
|
||||
@@ -187,12 +187,13 @@ proc testSpec(r: var TResults, test: TTest) =
|
||||
else:
|
||||
exeFile = changeFileExt(tname, ExeExt)
|
||||
if existsFile(exeFile):
|
||||
if test.target == targetJS and findExe("nodejs") == "":
|
||||
let nodejs = findNodeJs()
|
||||
if test.target == targetJS and nodejs == "":
|
||||
r.addResult(test, expected.outp, "nodejs binary not in PATH",
|
||||
reExeNotFound)
|
||||
return
|
||||
var (buf, exitCode) = execCmdEx(
|
||||
(if test.target == targetJS: "nodejs " else: "") & exeFile)
|
||||
(if test.target == targetJS: nodejs & " " else: "") & exeFile)
|
||||
if exitCode != expected.exitCode:
|
||||
r.addResult(test, "exitcode: " & $expected.exitCode,
|
||||
"exitcode: " & $exitCode, reExitCodesDiffer)
|
||||
|
||||
Reference in New Issue
Block a user