Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (target: Object) => {
const meta = optimal(
{
...config,
description,
path,
},
commandBlueprint,
{
name: path,
unknown: false,
},
);
Reflect.defineMetadata(META_PATH, meta.path, target);
Reflect.defineMetadata(META_CONFIG, meta, target);
// Also update static properties on constructor
throw new TypeError(`Cannot define option as class property "${property}" does not exist.`);
}
const options: CommandMetadata['options'] = Reflect.getMetadata(META_OPTIONS, target) ?? {};
const name = String(property);
let blueprint: Blueprint;
if (config.type === 'boolean') {
blueprint = flagBlueprint;
} else if (config.type === 'number') {
blueprint = config.multiple ? numbersOptionBlueprint : numberOptionBlueprint;
} else {
blueprint = config.multiple ? stringsOptionBlueprint : stringOptionBlueprint;
}
options[name] = optimal(config, blueprint as Blueprint, {
name: `Option "${name}"`,
unknown: false,
});
Reflect.defineMetadata(META_OPTIONS, options, target);
}