2024-11-08 05:21:56 -05:00
|
|
|
const fsPromises = require('node:fs/promises')
|
|
|
|
const { callbackify } = require('node:util')
|
2022-03-01 10:09:36 -05:00
|
|
|
const logger = require('@overleaf/logger')
|
2016-02-02 09:26:14 -05:00
|
|
|
|
2022-07-19 10:39:03 -04:00
|
|
|
async function injectDraftMode(filename) {
|
|
|
|
const content = await fsPromises.readFile(filename, { encoding: 'utf8' })
|
2022-07-22 04:12:18 -04:00
|
|
|
const modifiedContent =
|
|
|
|
'\\PassOptionsToPackage{draft}{graphicx}\\PassOptionsToPackage{draft}{graphics}' +
|
|
|
|
content
|
2022-07-19 10:39:03 -04:00
|
|
|
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' })
|
2020-02-19 06:14:37 -05:00
|
|
|
}
|
2022-07-07 08:27:20 -04:00
|
|
|
|
2022-07-19 10:39:03 -04:00
|
|
|
module.exports = {
|
|
|
|
injectDraftMode: callbackify(injectDraftMode),
|
|
|
|
promises: { injectDraftMode },
|
2022-07-07 08:27:20 -04:00
|
|
|
}
|