<commit_before># React = require 'react'

SDKError    = require './SDKError'
colors      = SDKError.colors

path        = require 'path'
fs          = require 'fs'
mime        = require 'mime'

module.exports = ({ project_directory, project, config, writeFile }) ->


    # Require the project's copy of React so that the below validation and
    # rendering will work. Fails silently since React is not required at this
    # point. (For some reason, different copies of React can't validate each
    # other's components?)
    project_react_path = path.join(project_directory, 'node_modules', 'react')
    if fs.existsSync(path.join(project_react_path, 'package.json'))
        React = require(project_react_path)

    _processContent = (file_content) ->
        switch typeof file_content
            when 'string'
                return [null, file_content]

            when 'object'
                if React?.isValidComponent(file_content)
                    output_content = React.renderComponentToStaticMarkup(file_content)
                    output_content = "<!doctype html>#{ output_content }"
                    unless process.env.NODE_ENV is 'production'
                        { prettyPrint } = require 'html'
                        output_content = prettyPrint(output_content)
                    return ['text/html', output_content]

                # It looks like a React component but somehow React wasn't
                # installed locally for the project.
                if file_content._store?.props?
                    SDKError.log('project.react', "Did you mean to render a React component? React MUST be installed locally for the project in order to pass `emitFile` a React component.")

                # Try turning the data into JSON
                try
                    output_content = JSON.stringify(file_content)
                catch e
                    throw new SDKError('emitFile.json', e)
                return ['application/json', output_content]<commit_msg>Remove pretty formatting of React HTML output.<commit_after># React = require 'react'

SDKError    = require './SDKError'
colors      = SDKError.colors

path        = require 'path'
fs          = require 'fs'
mime        = require 'mime'

module.exports = ({ project_directory, project, config, writeFile }) ->


    # Require the project's copy of React so that the below validation and
    # rendering will work. Fails silently since React is not required at this
    # point. (For some reason, different copies of React can't validate each
    # other's components?)
    project_react_path = path.join(project_directory, 'node_modules', 'react')
    if fs.existsSync(path.join(project_react_path, 'package.json'))
        React = require(project_react_path)

    _processContent = (file_content) ->
        switch typeof file_content
            when 'string'
                return [null, file_content]

            when 'object'
                if React?.isValidComponent(file_content)
                    output_content = React.renderComponentToStaticMarkup(file_content)
                    output_content = "<!doctype html>#{ output_content }"
                    return ['text/html', output_content]

                # It looks like a React component but somehow React wasn't
                # installed locally for the project.
                if file_content._store?.props?
                    SDKError.log('project.react', "Did you mean to render a React component? React MUST be installed locally for the project in order to pass `emitFile` a React component.")

                # Try turning the data into JSON
                try
                    output_content = JSON.stringify(file_content)
                catch e
                    throw new SDKError('emitFile.json', e)
                return ['application/json', output_content]
{'fraction_non_alphanumeric': 0.07740098369143153, 'fraction_numerical': 0.0, 'mean_word_length': 2.128744939271255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7452619', 'n_tokens_mistral': 974, 'n_tokens_neox': 905, 'n_words': 318}