no validation when appending core settings to fqbn

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-07-20 12:11:20 +02:00
parent 0ee9d16b40
commit c9dfc68911
2 changed files with 2 additions and 88 deletions

View File

@@ -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);