Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function validateCommand(command) {
const commandName = command.command
if (!commandName.startsWith('//')) {
let commandSchema = Commands.find(cmdObj => cmdObj[0] === commandName)
if (commandSchema) commandSchema = commandSchema[1]
else throw new Error(`Invalid command '${commandName}'`)
if (!!commandSchema.target !== !!command.target) {
const isOptional = !!commandSchema.target.isOptional
if (!isOptional) {
throw new Error(
`Incomplete command '${
command.command
}'. Missing expected target argument.`
)
}
}
if (!!commandSchema.value !== !!command.value) {
const isOptional = !!commandSchema.value.isOptional
if (!isOptional) {
throw new Error(