<commit_before>//
//  Build.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-11.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Commandant
import Foundation
import LlamaKit
import ReactiveCocoa

public struct BuildCommand: CommandType {
	public let verb = "build"
	public let function = "Build the project's dependencies"

	public func run(mode: CommandMode) -> Result<()> {
		return ColdSignal.fromResult(BuildOptions.evaluate(mode))
			.map { self.buildWithOptions($0) }
			.merge(identity)
			.wait()
	}

	/// Builds a project with the given options.
	public func buildWithOptions(options: BuildOptions) -> ColdSignal<()> {
		return self.openTemporaryLogFile()
			.map { (stdoutHandle, temporaryURL) -> ColdSignal<()> in
				let directoryURL = NSURL.fileURLWithPath(options.directoryPath, isDirectory: true)!

				let (stdoutSignal, schemeSignals) = self.buildProjectInDirectoryURL(directoryURL, options: options)
				let disposable = stdoutSignal.observe { data in
					stdoutHandle.writeData(data)
				}

				return schemeSignals
					.concat(identity)
					.on(subscribed: {
						println("*** xcodebuild output can be found in \(temporaryURL.path!)")
					}, next: { (project, scheme) in<commit_msg>Always flush Xcode log file after writing<commit_after>//
//  Build.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-11.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Commandant
import Foundation
import LlamaKit
import ReactiveCocoa

public struct BuildCommand: CommandType {
	public let verb = "build"
	public let function = "Build the project's dependencies"

	public func run(mode: CommandMode) -> Result<()> {
		return ColdSignal.fromResult(BuildOptions.evaluate(mode))
			.map { self.buildWithOptions($0) }
			.merge(identity)
			.wait()
	}

	/// Builds a project with the given options.
	public func buildWithOptions(options: BuildOptions) -> ColdSignal<()> {
		return self.openTemporaryLogFile()
			.map { (stdoutHandle, temporaryURL) -> ColdSignal<()> in
				let directoryURL = NSURL.fileURLWithPath(options.directoryPath, isDirectory: true)!

				let (stdoutSignal, schemeSignals) = self.buildProjectInDirectoryURL(directoryURL, options: options)
				let disposable = stdoutSignal.observe { data in
					stdoutHandle.writeData(data)
					stdoutHandle.synchronizeFile()
				}

				return schemeSignals
					.concat(identity)
					.on(subscribed: {
						println("*** xcodebuild output can be found in \(temporaryURL.path!)")
					}, next: { (project, scheme) in
{'fraction_non_alphanumeric': 0.11358313817330211, 'fraction_numerical': 0.01014832162373146, 'mean_word_length': 3.9670542635658914, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '4398839', 'n_tokens_mistral': 897, 'n_tokens_neox': 759, 'n_words': 212}