<commit_before>const fs      = require('fs')
const path    = require('path')
const mkdirp  = require('mkdirp')
const patched = require('../assets/commandLineRenderer.jsx')

const writeTo = (data, dst) => fs.writeFileSync(dst, data)
const copyTo = (src, dst) => fs.writeFileSync(dst, fs.readFileSync(src))

/**
 * Attempt to patch the After Effect's command line renderer
 * @type {Object}
 */
module.exports = (settings) => {
    const targetScript  = 'commandLineRenderer.jsx';

    const afterEffects = path.dirname(settings.binary)
    const originalFile = path.join(afterEffects, 'Scripts', 'Startup', targetScript)
    const backupFile   = path.join(afterEffects, 'Backup.Scripts', 'Startup', targetScript)

    const data = fs.readFileSync(originalFile, 'utf8')
    settings.logger.log('checking After Effects command line renderer patch...')

    /* check if file has been patched already */
    /* by looking for 'nexrender' in the text anywhere */
    if (data.indexOf('nexrender') !== -1) {
        settings.logger.log('command line patch already is in place')

        if (settings.forceCommandLinePatch) {
            settings.logger.log('forced rewrite of command line patch')
            writeTo(patched, originalFile)
        }
    } else {
        settings.logger.log('backing up original command line script to:')
        settings.logger.log(' - ' + backupFile)

        mkdirp.sync(path.join(afterEffects, 'Backup.Scripts', 'Startup'))
        copyTo(originalFile, backupFile)

        settings.logger.log('patching the command line script')
        writeTo(patched, originalFile)
    }
}<commit_msg>added chmod access to patch<commit_after>const fs      = require('fs')
const path    = require('path')
const mkdirp  = require('mkdirp')
const patched = require('../assets/commandLineRenderer.jsx')

const writeTo = (data, dst) => fs.writeFileSync(dst, data)
const copyTo = (src, dst) => fs.writeFileSync(dst, fs.readFileSync(src))

/**
 * Attempt to patch the After Effect's command line renderer
 * @type {Object}
 */
module.exports = (settings) => {
    const targetScript  = 'commandLineRenderer.jsx';

    const afterEffects = path.dirname(settings.binary)
    const originalFile = path.join(afterEffects, 'Scripts', 'Startup', targetScript)
    const backupFile   = path.join(afterEffects, 'Backup.Scripts', 'Startup', targetScript)

    const data = fs.readFileSync(originalFile, 'utf8')
    settings.logger.log('checking After Effects command line renderer patch...')

    /* check if file has been patched already */
    /* by looking for 'nexrender' in the text anywhere */
    if (data.indexOf('nexrender') !== -1) {
        settings.logger.log('command line patch already is in place')

        if (settings.forceCommandLinePatch) {
            settings.logger.log('forced rewrite of command line patch')
            writeTo(patched, originalFile)
        }
    } else {
        settings.logger.log('backing up original command line script to:')
        settings.logger.log(' - ' + backupFile)

        mkdirp.sync(path.join(afterEffects, 'Backup.Scripts', 'Startup'))
        copyTo(originalFile, backupFile)

        settings.logger.log('patching the command line script')
        fs.chmodSync(originalFile, '755');
        writeTo(patched, originalFile)
    }
}
{'fraction_non_alphanumeric': 0.12602490130580019, 'fraction_numerical': 0.0021257212268448226, 'mean_word_length': 3.4274193548387095, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3007724', 'n_tokens_mistral': 962, 'n_tokens_neox': 936, 'n_words': 252}