overleaf/services/clsi/app/js/DraftModeManager.js
Eric Mc Sween 9199669c0f Merge pull request #8921 from overleaf/em-draft-mode
Change draft mode implementation

GitOrigin-RevId: 3de81a3643cc024c410b7b49e77cd41c7fec8294
2022-07-20 08:04:06 +00:00

22 lines
722 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}' + 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 },
}