Skip to content

Commit

Permalink
fix: fix parse error as it will parse twice no matter what it is
Browse files Browse the repository at this point in the history
  • Loading branch information
polarlights committed Jul 4, 2020
1 parent 0cfacf9 commit 78220d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
1 change: 0 additions & 1 deletion bin/confluence-publisher
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path '../../lib', __FILE__
require 'asciidoctor/confluence_publisher/command'
require 'pry-byebug'

Asciidoctor::ConfluencePublisher::Command.execute ARGV
33 changes: 18 additions & 15 deletions lib/asciidoctor/confluence_publisher/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ def self.execute(args)
source_dir = nil
2.times do
result = options.parse! args
if result.is_a? Integer
if args.size == 1
file = args.first
fstat = ::File.stat file
if fstat.ftype == 'directory' && (input_files = parse_directory_files(file)).size > 0
source_dir = file
orig_args.reject! { |_arg| file == _arg }
orig_args.concat input_files
args = orig_args
else
exit result
end
else
exit result
end
break unless result.is_a? Integer

can_retry = false
if args.size == 1
source_dir = args.first
args = convert_directory_to_files(source_dir, orig_args)
can_retry = true
end
exit result unless can_retry
end

options[:asciidoc_source_dir] = source_dir
Expand All @@ -43,6 +36,16 @@ def self.execute(args)
end

private

def self.convert_directory_to_files(file, orig_args)
fstat = ::File.stat file
if fstat.ftype == 'directory' && (input_files = parse_directory_files(file)).size > 0
orig_args.reject! { |_arg| file == _arg }
orig_args.concat input_files
return orig_args
end
end

# hack asciidoctor to support folder
def self.parse_directory_files(directory)
infiles = []
Expand Down

0 comments on commit 78220d2

Please sign in to comment.