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

fix(compile): prevent setting unstable feature twice (#24381)

Prevent panic when enabling a feature that is already enabled by
removing duplicate features.

Closes #22015

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
HasanAlrimawi 2024-07-03 02:15:10 +03:00 committed by GitHub
parent 7d919f6fd9
commit 3324d7203e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 39 additions and 3 deletions

View file

@ -1773,14 +1773,28 @@ impl CliOptions {
.map(|c| c.json.unstable.clone())
.unwrap_or_default();
from_config_file.extend_from_slice(&self.flags.unstable_config.features);
self
.flags
.unstable_config
.features
.iter()
.for_each(|feature| {
if !from_config_file.contains(feature) {
from_config_file.push(feature.to_string());
}
});
if *DENO_FUTURE {
from_config_file.extend_from_slice(&[
let future_features = [
deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME.to_string(),
deno_runtime::deno_fs::UNSTABLE_FEATURE_NAME.to_string(),
deno_runtime::deno_webgpu::UNSTABLE_FEATURE_NAME.to_string(),
]);
];
future_features.iter().for_each(|future_feature| {
if !from_config_file.contains(future_feature) {
from_config_file.push(future_feature.to_string());
}
});
}
from_config_file

View file

@ -0,0 +1,2 @@
out.exe
out

View file

@ -0,0 +1,13 @@
{
"steps": [
{
"args": "compile --unstable-kv -A --output out main.ts",
"output": "compile.out"
},
{
"commandName": "./out",
"args": [],
"output": "main.out"
}
]
}

View file

@ -0,0 +1,2 @@
Check [WILDCARD]main.ts
Compile [WILDCARD]main.ts to out[WILDCARD]

View file

@ -0,0 +1,3 @@
{
"unstable": ["kv"]
}

View file

@ -0,0 +1 @@
Duplicate unstable feature issue is resolved as you can see

View file

@ -0,0 +1 @@
console.log("Duplicate unstable feature issue is resolved as you can see");