Skip to content

Commit 9401772

Browse files
author
iandol
committed
support pixi and some other tweaks
1 parent bf339fa commit 9401772

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

pandoc-run.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ def makePath() # this method augments our environment path
3333
puts "--> Modified path: #{ENV['PATH'].chomp}"
3434
end # end makePath()
3535

36-
def isRecent(infile) # checks if a file is less than 3 minutes old
37-
return false if !File.file?(infile)
38-
filetime = File.mtime(infile) # modified time
39-
Time.now - filetime <= 180 # compare to now
36+
#--------------------------------checks if a file is less than 3 minutes old
37+
def isRecent(infile)
38+
File.exist?(infile) && (Time.now - File.mtime(infile)) <= 180
4039
end
4140

4241
#binding.break

quarto-run.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ def makePath() # this method augments our environment path
3131
puts "--> Modified path: #{ENV['PATH'].chomp}"
3232
end
3333

34-
def isRecent(infile) # checks if a file is less than 3 minutes old
35-
return false if !File.file?(infile)
36-
filetime = File.mtime(infile) # modified time
37-
Time.now - filetime <= 180 # compare to now
34+
#--------------------------------checks if a file is less than 3 minutes old
35+
def isRecent(infile)
36+
File.exist?(infile) && (Time.now - File.mtime(infile)) <= 180
3837
end
3938

4039
tstart = Time.now

scrivomatic

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require 'open3' # ruby standard library class to handle stderr and stdout
1313
require 'optparse' # ruby standard option parser
1414
require 'fileutils' # ruby standard library to deal with files
1515
require 'shellwords' # escapes strings to run in the shell
16-
#require 'debug/open_nonstop'
16+
require 'debug/open_nonstop' # debugger, use binding.break to stop
1717

1818
##
1919
# main scrivomatic class
@@ -48,6 +48,11 @@ class Scrivomatic
4848
postBuild # run latexmk if we are building
4949
end
5050

51+
#--------------------------------checks if a file is less than 3 minutes old
52+
def isRecent(infile)
53+
File.exist?(infile) && (Time.now - File.mtime(infile)) <= 180
54+
end
55+
5156
#--------------------------------if we will run latexmk, remove old tex file before running pandoc
5257
def preBuild
5358
return unless options.build && !(options.dry_run)
@@ -120,7 +125,6 @@ class Scrivomatic
120125

121126
#-------------------------------run the command
122127
def runCommand
123-
`open scrivomatic.log` if @options[:open_log] && File.exist?('scrivomatic.log')
124128
puts '===------ COMMAND OUTPUT: ------===' if @options[:verbose] == true
125129
if File.exist?(@toolPath) && !options.dry_run
126130
puts ":: Running: #{@cmd}\n" if @options[:verbose] == true
@@ -136,6 +140,8 @@ class Scrivomatic
136140
puts "\n!!!---scrivomatic::runCommand() RETURN non-zero value: #{cmd}!!!"
137141
end
138142
end
143+
`open scrivomatic.log` if @options[:open_log] && isRecent('scrivomatic.log')
144+
`open pandocomatic.log` if @options[:open_log] && isRecent('pandocomatic.log')
139145
elsif !options.dry_run
140146
puts "Tool doesn't exist!!!" if @options[:verbose] == true
141147
puts "\n!!!---scrivomatic::runCommand() Couldn't find #{@toolPath} to run, please supply a proper path!"
@@ -225,7 +231,7 @@ class Scrivomatic
225231
texPath = options.input.gsub(/#{@fileext}$/, '.tex')
226232
texFile = texPath.gsub(/\\+/, '')
227233
pdfFile = texPath.gsub(/\.tex/, '.pdf')
228-
if File.exist?(texFile)
234+
if isRecent(texFile)
229235
if File.exist?(pdfFile)
230236
puts "\n===------ Remove old #{pdfFile} ------===" if @options[:verbose] == true
231237
File.delete(pdfFile)
@@ -261,7 +267,8 @@ class Scrivomatic
261267
end
262268
end
263269
end #--------------- end Scrivomatic class
264-
#binding.break
270+
271+
binding.break
265272
scriv = Scrivomatic.new
266273
scriv.parseInputs(ARGV)
267274
scriv.run

typst-run.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ def makePath() # this method augments our environment path
3939
end
4040
end # end makePath()
4141

42-
def isRecent(infile) # checks if a file is less than 3 minutes old
43-
return false if !File.file?(infile)
44-
filetime = File.mtime(infile) # modified time
45-
Time.now - filetime <= 180 # compare to now
42+
#--------------------------------checks if a file is less than 3 minutes old
43+
def isRecent(infile)
44+
File.exist?(infile) && (Time.now - File.mtime(infile)) <= 180
4645
end
4746

4847
infilename = File.expand_path(ARGV[0])

0 commit comments

Comments
 (0)