/*
 * grunt-audiotheme
 * http://audiotheme.com/
 *
 * Copyright (c) 2013 AudioTheme, LLC
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

	var pkg = grunt.file.readJSON('package.json');

	// Alias release task for faster access.
	grunt.registerTask('release', function(version) {
		version = version ? ':' + version : '';
		grunt.task.run('audiotheme-release' + version);
	});

	/**
	 * The main release task.
	 *
	 * Runs the build process first.
	 */
	grunt.registerTask('audiotheme-release', function(version) {
		version = version || pkg.version;

		grunt.task.requires('audiotheme-setup');

		if ('theme' === grunt.option('audiotheme-type')) {
			grunt.task.run('audiotheme-build:' + version);
			grunt.task.run('audiotheme-release-theme:' + version);
		}
	});

	/**
	 * Upload the theme.
	 *
	 * Uses credentials specified in config.json in the project root.
	 */
	grunt.registerTask('audiotheme-release-theme', function(version) {
		if (undefined === version) {
			grunt.warn('Version must be defined for the audiotheme-release-theme task.');
		}

		// @todo git tag, commit, and push to origin

		// Set a reference to the most recent build in order to upload it.
		if (undefined === grunt.config.get('sftp.release.files')) {
			grunt.config.set('sftp.release.files', {
				'./': ['release/' + pkg.name.toLowerCase() + '-' + version + '.zip']
			});
		}

		grunt.task.run('sftp:release');
	});

};

@@ -974,16 +974,92 @@
 sion) %7B%0A
+%09%09var file = 'release/' + pkg.name.toLowerCase() + '-' + version + '.zip';%0A%0A
 %09%09if (un
@@ -1173,52 +1173,108 @@
 %0A%0A%09%09
-// @todo git tag, commit, and push to origin
+if (!grunt.file.exists(file)) %7B%0A%09%09%09grunt.warn('The package archive doesn%5C't exist at: ' + file);%0A%09%09%7D
 %0A%0A%09%09
@@ -1461,68 +1461,14 @@
 ': %5B
-'release/' + pkg.name.toLowerCase() + '-' + version + '.zip'
+ file 
 %5D%0A%09%09

Test for the package archive in the release task.