diff --git a/lib/jsduck/source_writer.rb b/lib/jsduck/source_writer.rb index 770046176af8ba669b80316b4bab9331cbde275e..0b268c8aeabda8104aae526039c9126415691cec 100644 --- a/lib/jsduck/source_writer.rb +++ b/lib/jsduck/source_writer.rb @@ -26,7 +26,7 @@ module JsDuck def uniq_html_filename(filename) fname = html_filename(filename) nr = 1 - while File.exists?(fname) + while file_exists?(fname) nr += 1 fname = html_filename(filename, nr) end @@ -37,6 +37,12 @@ module JsDuck @output_dir + "/" + File.basename(filename, ".js") + (nr > 0 ? nr.to_s : "") + ".html" end + # Case-insensitive check for file existance to avoid conflicts + # when source files dir is moved to Windows machine. + def file_exists?(filename) + Dir.glob(filename, File::FNM_CASEFOLD).length > 0 + end + # Returns source wrapped inside HTML page def wrap_page(source) return <<-EOHTML