mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
9199669c0f
Change draft mode implementation GitOrigin-RevId: 3de81a3643cc024c410b7b49e77cd41c7fec8294
22 lines
722 B
JavaScript
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 },
|
|
}
|