def install
      fetch
      parse_package_json
      determine_name_and_version

      if !name || name.to_s =~ /^\s*$/ # blank
        raise(Jim::InstallError, "Could not determine name for #{@fetched_path}")
      end

      logger.info "Installing #{name} #{version}"
      logger.debug "fetched_path #{@fetched_path}"

      if options[:shallow]
        shallow_filename = [name, (version == "0" ? nil : version)].compact.join('-')
        final_path = install_path + "#{shallow_filename}#{fetched_path.extname}"
      else
        final_path = install_path + 'lib' + "#{name}-#{version}" + "#{name}.js"
      end

      if @fetched_path.directory?
        # install every js file
        installed_paths = []
        sub_options = options.merge({
          :name => nil,
          :version => nil,
          :parent_version => version,
          :package_json => package_json.merge("name" => nil)
        })
        Jim.each_path_in_directories([@fetched_path], '.js', IGNORE_DIRS) do |subfile|
          logger.debug "Found file #{subfile}"
          installed_paths << Jim::Installer.new(subfile, install_path, sub_options).install
        end
        logger.debug "Extracted to #{install_path}, #{installed_paths.length} file(s)"
        return installed_paths
      end

      logger.debug "Installing to #{final_path}"
      if final_path.exist?
        logger.debug "#{final_path} already exists"
        if options[:force]
          FileUtils.rm_rf(final_path)
        elsif Digest::MD5.hexdigest(File.read(final_path)) == Digest::MD5.hexdigest(File.read(@fetched_path))
          logger.warn "Duplicate file, skipping"
          return final_path
        else
          logger.error "Trying to install to #{final_path}, but file already exists and is different."
          return false
        end
      end

      Downlow.extract(@fetched_path, :destination => final_path, :tmp_dir => tmp_root)
      # install json
      install_package_json(final_path.dirname + 'package.json') if !options[:shallow]
      installed = final_path.directory? ? Dir.glob(final_path + '**/*').length : 1
      logger.debug "Extracted to #{final_path}, #{installed} file(s)"
      final_path
    ensure
      FileUtils.rm_rf(@fetched_path) if @fetched_path && @fetched_path.exist?
      final_path
    end
def install
      fetch
      parse_package_json
      determine_name_and_version

      if !name || name.to_s =~ /^\s*$/ # blank
        raise(Jim::InstallError, "Could not determine name for #{@fetched_path}")
      end

      logger.info "Installing #{name} #{version}"
      logger.debug "fetched_path #{@fetched_path}"

      if options[:shallow]
        shallow_filename = [name, (version == "0" ? nil : version)].compact.join('-')
        final_path = install_path + "#{shallow_filename}#{fetched_path.extname}"
      else
        final_path = install_path + 'lib' + "#{name}-#{version}" + "#{name}.js"
      end

      if @fetched_path.directory?
        # install every js file
        installed_paths = []
        sub_options = options.merge({
          :name => nil,
          :version => nil,
          :parent_version => version,
          :package_json => package_json.merge("name" => nil)
        })
        Jim.each_path_in_directories([@fetched_path], '.js', IGNORE_DIRS) do |subfile|
          logger.debug "Found file #{subfile}"
          installed_paths << Jim::Installer.new(subfile, install_path, sub_options).install
        end
        logger.debug "Extracted to #{install_path}, #{installed_paths.length} file(s)"
        return installed_paths
      end

      logger.debug "Installing to #{final_path}"
      if final_path.exist?
        logger.debug "#{final_path} already exists"
        if options[:force]
          FileUtils.rm_rf(final_path)
        elsif Digest::MD5.hexdigest(File.read(final_path)) == Digest::MD5.hexdigest(File.read(@fetched_path))
          logger.warn "Duplicate file, skipping"
          return final_path
        else
          logger.error "Trying to install to #{final_path}, but file already exists and is different."
          return false
        end
      end

      Downlow.extract(@fetched_path, :destination => final_path, :tmp_dir => tmp_root)
      # install json
      install_package_json(final_path.dirname + 'package.json') if !options[:shallow]
      installed = final_path.directory? ? Dir.glob(final_path + '**/*').length : 1
      logger.debug "Extracted to #{final_path}, #{installed} file(s)"
      final_path
    ensure
      FileUtils.rm_rf(@fetched_path) if @fetched_path && @fetched_path.exist?
      final_path
    end
Fetch and install the files determining their name and version if not provided.
 If the fetch_path contains a directory of files, it iterates over the directory
 installing each file that isn't in IGNORE_DIRS and a name and version can be
 determined for. It also installs a package.json file along side the JS file
 that contains meta data including the name and version, also merging with the
 original package.json if found.

 If options[:shallow] == true it will just copy the single file without any leading
 directories or a package.json. 'shallow' installation is used for Bundle#vendor