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

Implement --exclude option.

Allowing to exclude some of the input files.
Comes in handy for Windows users especially.

Fixes #216
parent 972995a1
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ module JsDuck

    def initialize
      @input_files = []
      @exclude = []

      @output_dir = nil
      @ignore_global = false
@@ -161,6 +162,7 @@ module JsDuck
    def parse!(argv)
      parse_options(argv)
      auto_detect_config_file unless @config_option_specified
      exclude_input_files
      validate

      if @custom_tag_paths.length > 0
@@ -268,6 +270,15 @@ module JsDuck
          JsDuck::Util::IO.encoding = encoding
        end

        opts.on('--exclude=PATH', "Exclude input file or directory.",
          "",
          "For example to include all the subdirs of",
          "/app/js except /app/js/new, run JSDuck with:",
          "",
          "  jsduck /app/js --exclude /app/js/new") do |path|
          @exclude << path
        end

        opts.separator ""
        opts.separator "Customizing output:"
        opts.separator ""
@@ -854,6 +865,15 @@ module JsDuck
      end
    end

    # When --exclude option used, removes the files matching the
    # exclude path from @input_files
    def exclude_input_files
      @exclude.each do |exclude_path|
        exclude_re = Regexp.new('\A' + Regexp.escape(canonical(exclude_path)))
        @input_files.reject! {|f| f =~ exclude_re }
      end
    end

    # Extracts files of first build in jsb file
    def extract_jsb_files(jsb_file)
      json = Util::Json.read(jsb_file)