mirror of
https://github.com/MeiK2333/river.git
synced 2025-11-04 14:49:40 +08:00
add language: TypeScript
This commit is contained in:
parent
a162ed4e43
commit
a2f016a66c
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,3 +12,5 @@ Cargo.lock
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.devcontainer
|
.devcontainer
|
||||||
|
|
||||||
|
nohup.out
|
||||||
|
|||||||
@ -39,6 +39,12 @@ RUN add-apt-repository -y ppa:longsleep/golang-backports && \
|
|||||||
RUN apt install -y default-jdk
|
RUN apt install -y default-jdk
|
||||||
|
|
||||||
# TODO: install other languages
|
# TODO: install other languages
|
||||||
|
# TODO: C#
|
||||||
|
# TODO: Ruby
|
||||||
|
# TODO: PHP
|
||||||
|
# TODO: Lisp
|
||||||
|
# TODO: Kotlin
|
||||||
|
# TODO: Haskell
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/*
|
RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|||||||
3
example/.gitignore
vendored
3
example/.gitignore
vendored
@ -3,3 +3,6 @@ venv/
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.out
|
*.out
|
||||||
*.class
|
*.class
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
|
node_modules
|
||||||
|
|||||||
@ -21,6 +21,8 @@ def judge(path, language):
|
|||||||
filename = "main.go"
|
filename = "main.go"
|
||||||
elif language == river_pb2.Node:
|
elif language == river_pb2.Node:
|
||||||
filename = "main.js"
|
filename = "main.js"
|
||||||
|
elif language == river_pb2.TypeScript:
|
||||||
|
filename = "main.ts"
|
||||||
with open(path.joinpath(filename), "rb") as fr:
|
with open(path.joinpath(filename), "rb") as fr:
|
||||||
code = fr.read()
|
code = fr.read()
|
||||||
with open(path.joinpath("in.txt"), "rb") as fr:
|
with open(path.joinpath("in.txt"), "rb") as fr:
|
||||||
@ -46,41 +48,46 @@ def judge(path, language):
|
|||||||
def run():
|
def run():
|
||||||
with grpc.insecure_channel("localhost:4003") as channel:
|
with grpc.insecure_channel("localhost:4003") as channel:
|
||||||
stub = river_pb2_grpc.RiverStub(channel)
|
stub = river_pb2_grpc.RiverStub(channel)
|
||||||
# for path in Path("java").iterdir():
|
for path in Path("java").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.Java)):
|
for item in stub.Judge(judge(path, river_pb2.Java)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
# for path in Path("c").iterdir():
|
for path in Path("c").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.C)):
|
for item in stub.Judge(judge(path, river_pb2.C)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
# for path in Path("cpp").iterdir():
|
for path in Path("cpp").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.Cpp)):
|
for item in stub.Judge(judge(path, river_pb2.Cpp)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
# for path in Path("py").iterdir():
|
for path in Path("py").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.Python)):
|
for item in stub.Judge(judge(path, river_pb2.Python)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
# for path in Path("rust").iterdir():
|
for path in Path("rust").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.Rust)):
|
for item in stub.Judge(judge(path, river_pb2.Rust)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
# for path in Path("go").iterdir():
|
for path in Path("go").iterdir():
|
||||||
# print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
# for item in stub.Judge(judge(path, river_pb2.Go)):
|
for item in stub.Judge(judge(path, river_pb2.Go)):
|
||||||
# print(item)
|
print(item)
|
||||||
# print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
for path in Path("node").iterdir():
|
for path in Path("node").iterdir():
|
||||||
print(f"开始评测 {path}")
|
print(f"开始评测 {path}")
|
||||||
for item in stub.Judge(judge(path, river_pb2.Node)):
|
for item in stub.Judge(judge(path, river_pb2.Node)):
|
||||||
print(item)
|
print(item)
|
||||||
print(f"{path} 评测完成")
|
print(f"{path} 评测完成")
|
||||||
|
for path in Path("ts").iterdir():
|
||||||
|
print(f"开始评测 {path}")
|
||||||
|
for item in stub.Judge(judge(path, river_pb2.TypeScript)):
|
||||||
|
print(item)
|
||||||
|
print(f"{path} 评测完成")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
1
example/ts/1000/.gitignore
vendored
Normal file
1
example/ts/1000/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
main.js
|
||||||
0
example/ts/1000/in.txt
Normal file
0
example/ts/1000/in.txt
Normal file
1
example/ts/1000/main.ts
Normal file
1
example/ts/1000/main.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("Hello World!");
|
||||||
1
example/ts/1000/out.txt
Normal file
1
example/ts/1000/out.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hello World!
|
||||||
1
example/ts/1001/.gitignore
vendored
Normal file
1
example/ts/1001/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
main.js
|
||||||
1
example/ts/1001/in.txt
Normal file
1
example/ts/1001/in.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
2 3
|
||||||
15
example/ts/1001/main.ts
Normal file
15
example/ts/1001/main.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as readline from 'readline';
|
||||||
|
|
||||||
|
const rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.on('line', (line: string) => {
|
||||||
|
var nums = line.split(' ');
|
||||||
|
var a = parseInt(nums[0]);
|
||||||
|
var b = parseInt(nums[1]);
|
||||||
|
var res = a + b;
|
||||||
|
console.log(res);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
1
example/ts/1001/out.txt
Normal file
1
example/ts/1001/out.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
5
|
||||||
@ -3,6 +3,10 @@
|
|||||||
echo "Hello World!"
|
echo "Hello World!"
|
||||||
# create judge dir
|
# create judge dir
|
||||||
mkdir -p /river/runner
|
mkdir -p /river/runner
|
||||||
|
# 运行的上层目录创建 node_modules,以便 Node 与 TypeScript 使用
|
||||||
|
cd /river/runner
|
||||||
|
npm init -y
|
||||||
|
npm i @types/node
|
||||||
|
|
||||||
cd /plugins/js
|
cd /plugins/js
|
||||||
npm install
|
npm install
|
||||||
|
|||||||
@ -42,7 +42,7 @@ pub async fn judger(
|
|||||||
Some(Language::Python) => "/usr/bin/python3.8 main.py",
|
Some(Language::Python) => "/usr/bin/python3.8 main.py",
|
||||||
Some(Language::Rust) => "./a.out",
|
Some(Language::Rust) => "./a.out",
|
||||||
Some(Language::Node) => "/usr/bin/node main.js",
|
Some(Language::Node) => "/usr/bin/node main.js",
|
||||||
Some(Language::TypeScript) => "node main.js",
|
Some(Language::TypeScript) => "/usr/bin/node main.js",
|
||||||
Some(Language::Go) => "./a.out",
|
Some(Language::Go) => "./a.out",
|
||||||
Some(Language::Java) => "/usr/bin/java -cp . Main",
|
Some(Language::Java) => "/usr/bin/java -cp . Main",
|
||||||
None => return Err(Error::LanguageNotFound(request.language)),
|
None => return Err(Error::LanguageNotFound(request.language)),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user