Preserve whitespace at the end of crontab contents (issue #95)
This commit is contained in:
parent
ca10a69e83
commit
c4abbefe00
@ -106,7 +106,11 @@ module Whenever
|
||||
end
|
||||
|
||||
def prepare(contents)
|
||||
contents.split("\n")[@options[:cut]..-1].join("\n")
|
||||
# Some cron implementations require all non-comment lines to be newline-terminated.
|
||||
# Preserve any whitespace at the end of contents. (issue #95)
|
||||
stripped_contents = contents.strip
|
||||
tail = contents[stripped_contents.length..-1]
|
||||
stripped_contents.split("\n")[@options[:cut]..-1].join("\n") + tail
|
||||
end
|
||||
|
||||
def comment_base
|
||||
|
@ -281,8 +281,7 @@ My whenever job that was already here
|
||||
# End Whenever generated tasks for: My identifier
|
||||
EXISTING_CRON
|
||||
|
||||
# here-doc adds an extra newline we need removed
|
||||
assert_equal existing.strip, @command.send(:prepare, existing)
|
||||
assert_equal existing, @command.send(:prepare, existing)
|
||||
end
|
||||
|
||||
should "trim off the top lines of the file" do
|
||||
@ -302,8 +301,7 @@ My whenever job that was already here
|
||||
# End Whenever generated tasks for: My identifier
|
||||
NEW_CRON
|
||||
|
||||
# here-doc adds an extra newline we need removed
|
||||
assert_equal new_cron.strip, @command.send(:prepare, existing)
|
||||
assert_equal new_cron, @command.send(:prepare, existing)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user