avoid adding draft mode more than once
This commit is contained in:
@@ -42,14 +42,12 @@ module.exports = CompileManager =
|
|||||||
logger.log project_id: request.project_id, user_id: request.user_id, time_taken: Date.now() - timer.start, "written files to disk"
|
logger.log project_id: request.project_id, user_id: request.user_id, time_taken: Date.now() - timer.start, "written files to disk"
|
||||||
timer.done()
|
timer.done()
|
||||||
|
|
||||||
# FIXME - for incremental compiles we don't want to inject this multiple times
|
|
||||||
injectDraftModeIfRequired = (callback) ->
|
injectDraftModeIfRequired = (callback) ->
|
||||||
if request.draft
|
if request.draft
|
||||||
DraftModeManager.injectDraftMode Path.join(compileDir, request.rootResourcePath), callback
|
DraftModeManager.injectDraftMode Path.join(compileDir, request.rootResourcePath), callback
|
||||||
else
|
else
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
# FIXME - for incremental compiles we may need to update output.tex every time
|
|
||||||
createTikzFileIfRequired = (callback) ->
|
createTikzFileIfRequired = (callback) ->
|
||||||
if TikzManager.needsOutputFile(request.rootResourcePath, resourceList)
|
if TikzManager.needsOutputFile(request.rootResourcePath, resourceList)
|
||||||
TikzManager.injectOutputFile compileDir, request.rootResourcePath, callback
|
TikzManager.injectOutputFile compileDir, request.rootResourcePath, callback
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ module.exports = DraftModeManager =
|
|||||||
injectDraftMode: (filename, callback = (error) ->) ->
|
injectDraftMode: (filename, callback = (error) ->) ->
|
||||||
fs.readFile filename, "utf8", (error, content) ->
|
fs.readFile filename, "utf8", (error, content) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
|
# avoid adding draft mode more than once
|
||||||
|
if content?.indexOf("\\documentclass\[draft") >= 0
|
||||||
|
return callback()
|
||||||
modified_content = DraftModeManager._injectDraftOption content
|
modified_content = DraftModeManager._injectDraftOption content
|
||||||
logger.log {
|
logger.log {
|
||||||
content: content.slice(0,1024), # \documentclass is normally v near the top
|
content: content.slice(0,1024), # \documentclass is normally v near the top
|
||||||
@@ -18,4 +21,4 @@ module.exports = DraftModeManager =
|
|||||||
# With existing options (must be first, otherwise both are applied)
|
# With existing options (must be first, otherwise both are applied)
|
||||||
.replace(/\\documentclass\[/g, "\\documentclass[draft,")
|
.replace(/\\documentclass\[/g, "\\documentclass[draft,")
|
||||||
# Without existing options
|
# Without existing options
|
||||||
.replace(/\\documentclass\{/g, "\\documentclass[draft]{")
|
.replace(/\\documentclass\{/g, "\\documentclass[draft]{")
|
||||||
|
|||||||
Reference in New Issue
Block a user