mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 00:59:24 -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:
parent
7d919f6fd9
commit
3324d7203e
7 changed files with 39 additions and 3 deletions
|
@ -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
|
||||
|
|
2
tests/specs/compile/repetitive_unstable_flag/.gitignore
vendored
Normal file
2
tests/specs/compile/repetitive_unstable_flag/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
out.exe
|
||||
out
|
13
tests/specs/compile/repetitive_unstable_flag/__test__.jsonc
Normal file
13
tests/specs/compile/repetitive_unstable_flag/__test__.jsonc
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"steps": [
|
||||
{
|
||||
"args": "compile --unstable-kv -A --output out main.ts",
|
||||
"output": "compile.out"
|
||||
},
|
||||
{
|
||||
"commandName": "./out",
|
||||
"args": [],
|
||||
"output": "main.out"
|
||||
}
|
||||
]
|
||||
}
|
2
tests/specs/compile/repetitive_unstable_flag/compile.out
Normal file
2
tests/specs/compile/repetitive_unstable_flag/compile.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
Check [WILDCARD]main.ts
|
||||
Compile [WILDCARD]main.ts to out[WILDCARD]
|
3
tests/specs/compile/repetitive_unstable_flag/deno.json
Normal file
3
tests/specs/compile/repetitive_unstable_flag/deno.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"unstable": ["kv"]
|
||||
}
|
1
tests/specs/compile/repetitive_unstable_flag/main.out
Normal file
1
tests/specs/compile/repetitive_unstable_flag/main.out
Normal file
|
@ -0,0 +1 @@
|
|||
Duplicate unstable feature issue is resolved as you can see
|
1
tests/specs/compile/repetitive_unstable_flag/main.ts
Normal file
1
tests/specs/compile/repetitive_unstable_flag/main.ts
Normal file
|
@ -0,0 +1 @@
|
|||
console.log("Duplicate unstable feature issue is resolved as you can see");
|
Loading…
Reference in a new issue