<commit_before>fs = require "fs"
Path = require "path"
spawn = require("child_process").spawn
logger = require "logger-sharelatex"
_ = require "underscore"

module.exports = OutputFileOptimiser =

	optimiseFile: (src, dst, callback = (error) ->) ->
		# check output file (src) and see if we can optimise it, storing
		# the result in the build directory (dst)
		if src.match(/\.pdf$/)
			OutputFileOptimiser.optimisePDF src, dst, callback
		else
			callback (null)

	optimisePDF: (src, dst, callback = (error) ->) ->
		tmpOutput = dst + '.opt'
		args = ["--linearize", src, tmpOutput]
		logger.log args: args, "running qpdf command"<commit_msg>only run qpdf for the main output.pdf file<commit_after>fs = require "fs"
Path = require "path"
spawn = require("child_process").spawn
logger = require "logger-sharelatex"
_ = require "underscore"

module.exports = OutputFileOptimiser =

	optimiseFile: (src, dst, callback = (error) ->) ->
		# check output file (src) and see if we can optimise it, storing
		# the result in the build directory (dst)
		if src.match(/\/output\.pdf$/)
			OutputFileOptimiser.optimisePDF src, dst, callback
		else
			callback (null)

	optimisePDF: (src, dst, callback = (error) ->) ->
		tmpOutput = dst + '.opt'
		args = ["--linearize", src, tmpOutput]
		logger.log args: args, "running qpdf command"
{'fraction_non_alphanumeric': 0.1350943396226415, 'fraction_numerical': 0.0, 'mean_word_length': 4.0418250950570345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6871579', 'n_tokens_mistral': 462, 'n_tokens_neox': 430, 'n_words': 138}