mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix: add warning for invalid unstable feature use in deno.json/jsonc (#24120)
This commit is contained in:
parent
e30ad77ffa
commit
c3b168f5a2
5 changed files with 62 additions and 0 deletions
|
@ -1660,6 +1660,34 @@ impl CliOptions {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !from_config_file.is_empty() {
|
||||||
|
// collect unstable granular flags
|
||||||
|
let mut all_valid_unstable_flags: Vec<&str> =
|
||||||
|
crate::UNSTABLE_GRANULAR_FLAGS
|
||||||
|
.iter()
|
||||||
|
.map(|granular_flag| granular_flag.0)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let mut another_unstable_flags =
|
||||||
|
Vec::from(["sloppy-imports", "byonm", "bare-node-builtins"]);
|
||||||
|
// add more unstable flags to the same vector holding granular flags
|
||||||
|
all_valid_unstable_flags.append(&mut another_unstable_flags);
|
||||||
|
|
||||||
|
// check and warn if the unstable flag of config file isn't supported, by
|
||||||
|
// iterating through the vector holding the unstable flags
|
||||||
|
for unstable_value_from_config_file in &from_config_file {
|
||||||
|
if !all_valid_unstable_flags
|
||||||
|
.contains(&unstable_value_from_config_file.as_str())
|
||||||
|
{
|
||||||
|
log::warn!(
|
||||||
|
"{} '{}' isn't a valid unstable feature",
|
||||||
|
colors::yellow("Warning"),
|
||||||
|
unstable_value_from_config_file
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
from_config_file
|
from_config_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
tests/specs/task/invalid_unstable_feature/__test__.jsonc
Normal file
6
tests/specs/task/invalid_unstable_feature/__test__.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"steps": [{
|
||||||
|
"args": "task start",
|
||||||
|
"output": "invalid_unstable_feature.out"
|
||||||
|
}]
|
||||||
|
}
|
22
tests/specs/task/invalid_unstable_feature/deno.json
Normal file
22
tests/specs/task/invalid_unstable_feature/deno.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"tasks": {
|
||||||
|
"start": "deno run index.js"
|
||||||
|
},
|
||||||
|
"unstable": [
|
||||||
|
"abc",
|
||||||
|
"byonm",
|
||||||
|
"bare-node-builtins",
|
||||||
|
"sloppy-imports",
|
||||||
|
"unsafe-proto",
|
||||||
|
"webgpu",
|
||||||
|
"broadcast-channel",
|
||||||
|
"worker-options",
|
||||||
|
"cron",
|
||||||
|
"kv",
|
||||||
|
"ffi",
|
||||||
|
"fs",
|
||||||
|
"net",
|
||||||
|
"http",
|
||||||
|
"cba"
|
||||||
|
]
|
||||||
|
}
|
1
tests/specs/task/invalid_unstable_feature/index.js
Normal file
1
tests/specs/task/invalid_unstable_feature/index.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
console.log("Hello unstable features");
|
|
@ -0,0 +1,5 @@
|
||||||
|
Task start deno run index.js
|
||||||
|
Warning Sloppy imports are not recommended and have a negative impact on performance.
|
||||||
|
Warning 'abc' isn't a valid unstable feature
|
||||||
|
Warning 'cba' isn't a valid unstable feature
|
||||||
|
Hello unstable features
|
Loading…
Reference in a new issue