mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 00:35:28 -05:00
9ea1226460
Apply draft mode to graphics package as well (in addition to graphicx) GitOrigin-RevId: 6137f90ef9d579f0e6554801e8f2e0f5dee2aa83
24 lines
769 B
JavaScript
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 },
|
|
}
|