overleaf/services/clsi/app/js/DraftModeManager.js
Brian Gough 9ea1226460 Merge pull request #8969 from overleaf/bg-issue8967
Apply draft mode to graphics package as well (in addition to graphicx)

GitOrigin-RevId: 6137f90ef9d579f0e6554801e8f2e0f5dee2aa83
2022-07-25 08:03:57 +00:00

24 lines
769 B
JavaScript

const fsPromises = require('fs/promises')
const { callbackify } = require('util')
const logger = require('@overleaf/logger')
async function injectDraftMode(filename) {
const content = await fsPromises.readFile(filename, { encoding: 'utf8' })
const modifiedContent =
'\\PassOptionsToPackage{draft}{graphicx}\\PassOptionsToPackage{draft}{graphics}' +
content
logger.debug(
{
content: content.slice(0, 1024), // \documentclass is normally v near the top
modifiedContent: modifiedContent.slice(0, 1024),
filename,
},
'injected draft class'
)
await fsPromises.writeFile(filename, modifiedContent, { encoding: 'utf8' })
}
module.exports = {
injectDraftMode: callbackify(injectDraftMode),
promises: { injectDraftMode },
}