1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(repl): importing json files (#26053)

Closes https://github.com/denoland/deno/issues/26041
This commit is contained in:
Bartek Iwańczuk 2024-10-09 09:04:44 +01:00 committed by GitHub
parent 0dfd333649
commit 20ae8db50d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 3 deletions

4
Cargo.lock generated
View file

@ -1283,9 +1283,9 @@ dependencies = [
[[package]]
name = "deno_ast"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ea2fd038c9c7e3e87e624fd708303cd33f39c33707f6c48fa9a65d65fefc47"
checksum = "b2b9d03b1bbeeecdac54367f075d572131736d06c5be3bc49037855bc5ab1bbb"
dependencies = [
"base64 0.21.7",
"deno_media_type",

View file

@ -45,7 +45,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"
[workspace.dependencies]
deno_ast = { version = "=0.42.1", features = ["transpiling"] }
deno_ast = { version = "=0.42.2", features = ["transpiling"] }
deno_core = { version = "0.311.0" }
deno_bench_util = { version = "0.165.0", path = "./bench_util" }

View file

@ -1136,3 +1136,22 @@ fn eval_file_promise_error() {
assert_contains!(out, "Uncaught undefined");
assert!(err.is_empty());
}
#[test]
fn repl_json_imports() {
let context = TestContextBuilder::default().use_temp_cwd().build();
let temp_dir = context.temp_dir();
temp_dir.write("./data.json", r#"{"hello": "world"}"#);
context
.new_command()
.env("NO_COLOR", "1")
.args_vec(["repl", "-A"])
.with_pty(|mut console| {
console.write_line_raw(
"import data from './data.json' with { type: 'json' };",
);
console.expect("undefined");
console.write_line_raw("data");
console.expect(r#"{ hello: "world" }"#);
});
}