Commit e53e1653 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Check source files existance case insensitively.

The resulting documentation may otherwise contain files like
JSON.html and Json.html, which are different in UNIX, but will
cause a conflict when transferred to Windows.

Now doing a case-insensitive file_exists? check even on UNIX.
parent 94d4ca21
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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