<commit_before>var _ = require('underscore');
var AWS = require('aws-sdk');
var ApiGateway = require('../aws/api-gateway');

module.exports = {
	buildLambdaInvoke: function (folder, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					file_name: folder + '/' + name + '/index.js',
					event: folder + '/' + name + '/event.json'
				}
			};
		});

		return config;
	},
	buildLambdaPackage: function (folder, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					include_time: false,
					package_folder: folder + '/' + name,
					dist_folder: folder + '/' + name + '/dist'
				}
			};
		});

		return config;
	},
	buildLambdaDeploy: function (profile, region, account, prefix, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					profile: profile
				},
				arn: 'arn:aws:lambda:' + region + ':' + account + ':function:' + (prefix ? prefix + '-' : '') + name
			};
		});

		return config;
	},
	buildLambdaTest: function (names) {
		var config = {
			api: _.map(names, function (name) {
				return 'test/lambda/' + name + '/test.js';
			})
		};

		_.each(names, function (name) {
			config[name] = 'test/lambda/' + name + '/test.js';
		});

		return config;
	},
	addLambdas: function (config, profile, region, account, folder, prefix, names) {
		config.lambda_invoke = this.buildLambdaInvoke(folder, names);
		config.lambda_package = this.buildLambdaPackage(folder, names);
		config.lambda_deploy = this.buildLambdaDeploy(profile, region, account, prefix, names);
		config.nodeunit.api = this.buildLambdaTest(names);
	},
	registerLambdaTasks: function (grunt, names) {
		grunt.loadNpmTasks('grunt-contrib-nodeunit');
		grunt.loadNpmTasks('grunt-aws-lambda');

		_.each(names, function (name) {
			grunt.registerTask('run-' + name, ['lambda_invoke:' + name]);
			grunt.registerTask('deploy-' + name, ['lambda_package:' + name, 'lambda_deploy:' + name]);
			grunt.registerTask('test-' + name, ['nodeunit:' + name]);
		});

		grunt.registerMultiTask('apiDefinition', 'deploys a swagger api', function () {
			ApiGateway.deploy(this, grunt, AWS);
		});

		grunt.registerTask('deploy-api-definition', 'apiDefinition:deploy');
		grunt.registerTask('deploy-api', _.flatten(['nodeunit:api', _.map(names, function (name) {
				return 'deploy-' + name;
			}), 'deploy-api-definition']));
	}
}<commit_msg>add deployTasks to end of deploy-api<commit_after>var _ = require('underscore');
var AWS = require('aws-sdk');
var ApiGateway = require('../aws/api-gateway');

module.exports = {
	buildLambdaInvoke: function (folder, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					file_name: folder + '/' + name + '/index.js',
					event: folder + '/' + name + '/event.json'
				}
			};
		});

		return config;
	},
	buildLambdaPackage: function (folder, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					include_time: false,
					package_folder: folder + '/' + name,
					dist_folder: folder + '/' + name + '/dist'
				}
			};
		});

		return config;
	},
	buildLambdaDeploy: function (profile, region, account, prefix, names) {
		var config = {};

		_.each(names, function (name) {
			config[name] = {
				options: {
					profile: profile
				},
				arn: 'arn:aws:lambda:' + region + ':' + account + ':function:' + (prefix ? prefix + '-' : '') + name
			};
		});

		return config;
	},
	buildLambdaTest: function (names) {
		var config = {
			api: _.map(names, function (name) {
				return 'test/lambda/' + name + '/test.js';
			})
		};

		_.each(names, function (name) {
			config[name] = 'test/lambda/' + name + '/test.js';
		});

		return config;
	},
	addLambdas: function (config, profile, region, account, folder, prefix, names) {
		config.lambda_invoke = this.buildLambdaInvoke(folder, names);
		config.lambda_package = this.buildLambdaPackage(folder, names);
		config.lambda_deploy = this.buildLambdaDeploy(profile, region, account, prefix, names);
		config.nodeunit.api = this.buildLambdaTest(names);
	},
	registerLambdaTasks: function (grunt, names, deployTasks) {
		grunt.loadNpmTasks('grunt-contrib-nodeunit');
		grunt.loadNpmTasks('grunt-aws-lambda');

		_.each(names, function (name) {
			grunt.registerTask('run-' + name, ['lambda_invoke:' + name]);
			grunt.registerTask('deploy-' + name, ['lambda_package:' + name, 'lambda_deploy:' + name]);
			grunt.registerTask('test-' + name, ['nodeunit:' + name]);
		});

		grunt.registerMultiTask('apiDefinition', 'deploys a swagger api', function () {
			ApiGateway.deploy(this, grunt, AWS);
		});

		grunt.registerTask('deploy-api-definition', 'apiDefinition:deploy');
		grunt.registerTask('deploy-api', _.flatten(['nodeunit:api', _.map(names, function (name) {
				return 'deploy-' + name;
			}), 'deploy-api-definition', deployTasks]));
	}
}
{'fraction_non_alphanumeric': 0.17980944658422868, 'fraction_numerical': 0.0, 'mean_word_length': 3.6767772511848342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6156260', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1618, 'n_words': 339}