sample/gulp/gulpfile.js
function downloadProjectCompilation(project, platform, outputDir) {
	return waitForCompletion(project)
	.then(() => {
		if (project.compilations[platform]) {
			if (project.compilations[platform].isReady()) {
				return downloadFile(project.compilations[platform].downloadLink,
					outputDir + "/" + project.name + "-" + platform + ".zip")
				.catch((error) => {
					console.error("Couldn't download " + platform + " compilation from project " + project.id + ".");
					console.trace(error);
					throw error;
				});
			} else if (project.compilations[platform].isErred()) {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". The compilation failed.");
				throw new Error("Compilation failed");
			} else {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". Status: " + project.compilations[platform].status + ".");
				throw new Error("Platform ignored");
			}
		} else {
			console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
				". There was not a compilation issued for the platform.");
			throw new Error("No compilation available");
		}
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
function downloadProjectCompilation(project, platform, outputDir) {
	return waitForCompletion(project)
	.then(() => {
		if (project.compilations[platform]) {
			if (project.compilations[platform].isReady()) {
				return downloadFile(project.compilations[platform].downloadLink,
					outputDir + "/" + project.name + "-" + platform + ".zip")
				.catch((error) => {
					console.error("Couldn't download " + platform + " compilation from project " + project.id + ".");
					console.trace(error);
					throw error;
				});
			} else if (project.compilations[platform].isErred()) {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". The compilation failed.");
				throw new Error("Compilation failed");
			} else {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". Status: " + project.compilations[platform].status + ".");
				throw new Error("Platform ignored");
			}
		} else {
			console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
				". There was not a compilation issued for the platform.");
			throw new Error("No compilation available");
		}
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
function downloadProjectCompilation ( project , platform , outputDir ) { return waitForCompletion ( project ) . then ( ( ) => { if ( project . compilations [ platform ] ) { if ( project . compilations [ platform ] . isReady ( ) ) { return downloadFile ( project . compilations [ platform ] . downloadLink , outputDir + "/" + project . name + "-" + platform + ".zip" ) . catch ( ( error ) => { console . error ( "Couldn't download " + platform + " compilation from project " + project . id + "." ) ; console . trace ( error ) ; throw error ; } ) ; } else if ( project . compilations [ platform ] . isErred ( ) ) { console . error ( "Couldn't download " + platform + " compilation from " + project . name + " project: " + project . id + ". The compilation failed." ) ; throw new Error ( "Compilation failed" ) ; } else { console . error ( "Couldn't download " + platform + " compilation from " + project . name + " project: " + project . id + ". Status: " + project . compilations [ platform ] . status + "." ) ; throw new Error ( "Platform ignored" ) ; } } else { console . error ( "Couldn't download " + platform + " compilation from " + project . name + " project: " + project . id + ". There was not a compilation issued for the platform." ) ; throw new Error ( "No compilation available" ) ; } } ) . catch ( ( error ) => { console . trace ( error ) ; throw error ; } ) ; }
Downloads the result of the latest platform compilation of the project
@param {Project} project
@param {string} platform
@param {string} outputDir
@return {Promise<void>}
Downloads the result of the latest platform compilation of the project