Skip to content

Commit ea55ae2

Browse files
committed
add javscript support
1 parent b2e5bd6 commit ea55ae2

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ Returns the result (stdout) of the executed code. If stderr is not empty, an exc
5555

5656
_input_: string – The code you want to execute.
5757

58-
_language_: cee.Language – Pass the language the code is written in, for example `cee.languages.PYTHON3`
58+
_language_: cee.Language – Pass the language the code is written in, for example `cee.languages.PYTHON3`. [Supported Lanuages](#supported-languages)
5959

6060
<a name="supported-languages"/>
6161

6262
## Supported Languages
6363

6464
- **Python3** (Windows / Linux)
65+
- **Javascript** (Windows / Linux)
6566
- **Batch** (Windows)
6667
- **Bash** (Linux)
6768
- **C** (Linux)

runners/linux/js.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
timeout -s SIGKILL 10 node $1

runners/win32/js.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
node %1

src/executor.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import path from "path";
66

77
const uniqueFilename = require("unique-filename");
88

9-
interface IOptions {
10-
timeout?: number;
11-
}
12-
139
/**
1410
*
1511
* @param input The code that should be executed
@@ -20,8 +16,7 @@ interface IOptions {
2016
*/
2117
export default async function execute(
2218
input: string,
23-
language: Language,
24-
options?: IOptions
19+
language: Language
2520
): Promise<string> {
2621
// Check Platform
2722
const os = platform();

src/languages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ enum Language {
22
PYTHON3 = "python3",
33
C = "gcc",
44
BASH = "bash",
5-
BATCH = "bat"
5+
BATCH = "bat",
6+
JAVASCRIPT = "js",
67
}
78

89
export default Language;

tests/all.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ describe("Testing Basic Languages", () => {
66
expect(response).toBe("123");
77
});
88
});
9+
test("JS", () => {
10+
return cee
11+
.execute("console.log(123)", cee.languages.JAVASCRIPT)
12+
.then((response) => {
13+
expect(response).toBe("123");
14+
});
15+
});
916
// test("LXC", () => {
1017
// var executor = new cee.LXC("cee");
1118
// return executor.execute("whoami", cee.languages.BASH).then((response) => {

0 commit comments

Comments
 (0)