Skip to content

Commit 07cadb1

Browse files
committed
Return js kernel
1 parent 720b01e commit 07cadb1

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

js/tests/languages/js.test.ts renamed to js/tests/languages/deno.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { expect } from 'vitest'
33
import { sandboxTest } from '../setup'
44

55
sandboxTest('js simple', async ({ sandbox }) => {
6-
const result = await sandbox.runCode('console.log("Hello, World!")', {language: "js"})
6+
const result = await sandbox.runCode('console.log("Hello, World!")', {language: "deno"})
77

88
expect(result.logs.stdout.join().trim()).toEqual('Hello, World!')
99
})
1010

1111
sandboxTest('js import', async ({ sandbox }) => {
12-
const result = await sandbox.runCode('import isOdd from "npm:is-odd"\nisOdd(3)', {language: "js"})
12+
const result = await sandbox.runCode('import isOdd from "npm:is-odd"\nisOdd(3)', {language: "deno"})
1313

1414
expect(result.results[0].text).toEqual('true')
1515
})
@@ -21,30 +21,29 @@ sandboxTest('js top level await', async ({ sandbox }) => {
2121
}
2222
2323
await main()
24-
`, {language: "js"})
24+
`, {language: "deno"})
2525
expect(result.results[0].text).toEqual('Hello, World!')
2626
})
2727

2828
sandboxTest('js es6', async ({ sandbox }) => {
2929
const result = await sandbox.runCode(`
30-
const add = (x, y) => x + y;
31-
add(1, 2)
32-
`, {language: "js"})
30+
const add = (x, y) => x + y;
31+
add(1, 2)`, {language: "deno"})
3332
expect(result.results[0].text).toEqual('3')
3433
})
3534

3635

3736
sandboxTest('js context', async ({ sandbox }) => {
38-
await sandbox.runCode('const z = 1', {language: "js"})
39-
const result = await sandbox.runCode('z', {language: "js"})
37+
await sandbox.runCode('const z = 1', {language: "deno"})
38+
const result = await sandbox.runCode('z', {language: "deno"})
4039
expect(result.results[0].text).toEqual('1')
4140
})
4241

4342
sandboxTest('js cwd', async ({ sandbox }) => {
44-
const result = await sandbox.runCode('process.cwd()', {language: "js"})
43+
const result = await sandbox.runCode('process.cwd()', {language: "deno})
4544
expect(result.results[0].text).toEqual('/home/user')
4645

47-
const ctx = await sandbox.createCodeContext( {cwd: '/home', language: "js"})
46+
const ctx = await sandbox.createCodeContext( {cwd: '/home', language: "deno"})
4847
const result2 = await sandbox.runCode('process.cwd()', {context: ctx})
4948
expect(result2.results[0].text).toEqual('/home')
5049
})
@@ -56,7 +55,7 @@ function subtract(x: number, y: number): number {
5655
}
5756
5857
subtract(1, 2)
59-
`, {language: "ts"})
58+
`, {language: "deno"})
6059

6160
expect(result.results[0].text).toEqual('-1')
6261
})

python/tests/languages/test_js.py renamed to python/tests/languages/test_deno.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async def test_javascript(async_sandbox: AsyncSandbox):
55
code = """
66
console.log('Hello, World!')
77
"""
8-
execution = await async_sandbox.run_code(code, language="js")
8+
execution = await async_sandbox.run_code(code, language="deno")
99
assert execution.logs.stdout == ["Hello, World!\n"]
1010

1111

@@ -14,7 +14,7 @@ async def test_import(async_sandbox: AsyncSandbox):
1414
import isOdd from 'npm:is-odd'
1515
isOdd(3)
1616
"""
17-
execution = await async_sandbox.run_code(code, language="js")
17+
execution = await async_sandbox.run_code(code, language="deno")
1818
assert execution.results[0].text == "true"
1919

2020

@@ -26,7 +26,7 @@ async def test_toplevel_await(async_sandbox: AsyncSandbox):
2626
2727
await main()
2828
"""
29-
execution = await async_sandbox.run_code(code, language="js")
29+
execution = await async_sandbox.run_code(code, language="deno")
3030
assert execution.results[0].text == "Hello, World!"
3131

3232

@@ -35,21 +35,21 @@ async def test_es6(async_sandbox: AsyncSandbox):
3535
const add = (x, y) => x + y;
3636
add(1, 2);
3737
"""
38-
execution = await async_sandbox.run_code(code, language="js")
38+
execution = await async_sandbox.run_code(code, language="deno")
3939
assert execution.results[0].text == "3"
4040

4141

4242
async def test_context(async_sandbox: AsyncSandbox):
43-
await async_sandbox.run_code("const x = 1", language="js")
44-
execution = await async_sandbox.run_code("x", language="js")
43+
await async_sandbox.run_code("const x = 1", language="deno")
44+
execution = await async_sandbox.run_code("x", language="deno")
4545
assert execution.results[0].text == "1"
4646

4747

4848
async def test_cwd(async_sandbox: AsyncSandbox):
49-
execution = await async_sandbox.run_code("process.cwd()", language="js")
49+
execution = await async_sandbox.run_code("process.cwd()", language="deno")
5050
assert execution.results[0].text == "/home/user"
5151

52-
ctx = await async_sandbox.create_code_context("/home", language="js")
52+
ctx = await async_sandbox.create_code_context("/home", language="deno")
5353
execution = await async_sandbox.run_code("process.cwd()", context=ctx)
5454
assert execution.results[0].text == "/home"
5555

@@ -63,6 +63,6 @@ async def test_typescript(async_sandbox: AsyncSandbox):
6363
6464
subtract(1, 2);
6565
""",
66-
language="ts",
66+
language="deno",
6767
)
6868
assert execution.results[0].text == "-1"

template/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ RUN R -e "install.packages('IRkernel')"
2323
RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')"
2424

2525
# Javascript Kernel
26+
RUN npm install -g node-gyp
27+
RUN npm install -g --unsafe-perm ijavascript
28+
RUN ijsinstall --install=global
29+
30+
# Deno Kernel
2631
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
2732
RUN chmod +x /usr/bin/deno
2833
RUN deno jupyter --unstable --install

template/server/contexts.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@ def normalize_language(language: Optional[str]) -> str:
2020

2121
if language == "js":
2222
return "javascript"
23-
if language == "ts":
24-
return "typescript"
2523

2624
return language
2725

2826

2927
async def create_context(client, websockets: dict, language: str, cwd: str) -> Context:
30-
if language == "javascript" or language == "typescript":
31-
language = "deno"
32-
3328
data = {
3429
"path": str(uuid.uuid4()),
3530
"kernel": {"name": language},

template/test.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ COPY ./template/requirements.txt requirements.txt
1919
RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user
2020

2121
# Javascript Kernel
22+
RUN npm install -g node-gyp
23+
RUN npm install -g --unsafe-perm ijavascript
24+
RUN ijsinstall --install=global
25+
26+
# Deno Kernel
2227
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
2328
RUN chmod +x /usr/bin/deno
2429
RUN deno jupyter --unstable --install

0 commit comments

Comments
 (0)