Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function main(parsed, callback) {
if (parsed.command === 'init') {
lambdaCfn.init(parsed.environment, function(err, data) {
if (err) return callback({message: err});
return callback(null, data);
});
} else {
// Setup commands, make sure that CLI request uses a valid command
let available = cfnConfig.commands(parsed.options);
if (!available[parsed.command]) {
return callback({ message: 'Error: invalid command\n\n' + parsed.help });
}
// Check for valid environment
if (!parsed.environment) {
return callback({ message: 'Error: missing environment\n\n' + parsed.help });
}
// Check for template path on create and update
if (/create|update/.test(parsed.command) && !parsed.templatePath) {
return callback({ message: 'Error: missing templatePath\n\n' + parsed.help });
}
// Set the arguments for the command that will run