mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-08-23 18:19:25 +00:00
no validation when appending core settings to fqbn
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -229,18 +229,8 @@ export namespace ConfigOption {
|
||||
* Appends the configuration options to the `fqbn` argument.
|
||||
* Throws an error if the `fqbn` does not have the `segment(':'segment)*` format.
|
||||
* The provided output format is always segment(':'segment)*(':'option'='value(','option'='value)*)?
|
||||
* Validation can be disabled with the `{ validation: false }` option.
|
||||
*/
|
||||
export function decorate(fqbn: string, configOptions: ConfigOption[], { validate } = { validate: true }): string {
|
||||
if (validate) {
|
||||
if (!isValidFqbn(fqbn)) {
|
||||
throw new ConfigOptionError(`${fqbn} is not a valid FQBN.`);
|
||||
}
|
||||
if (isValidFqbnWithOptions(fqbn)) {
|
||||
throw new ConfigOptionError(`${fqbn} is already decorated with the configuration options.`);
|
||||
}
|
||||
}
|
||||
|
||||
export function decorate(fqbn: string, configOptions: ConfigOption[]): string {
|
||||
if (!configOptions.length) {
|
||||
return fqbn;
|
||||
}
|
||||
@@ -262,14 +252,6 @@ export namespace ConfigOption {
|
||||
return `${fqbn}:${options}`;
|
||||
}
|
||||
|
||||
export function isValidFqbn(fqbn: string): boolean {
|
||||
return /^\w+(:\w+)*$/.test(fqbn);
|
||||
}
|
||||
|
||||
export function isValidFqbnWithOptions(fqbn: string): boolean {
|
||||
return /^\w+(:\w+)*(:\w+=\w+(,\w+=\w+)*)$/.test(fqbn);
|
||||
}
|
||||
|
||||
export class ConfigOptionError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
|
Reference in New Issue
Block a user