Skip to content

Commit

Permalink
add comments and do small optimization up
Browse files Browse the repository at this point in the history
  • Loading branch information
Borzik committed Sep 25, 2016
1 parent 45cf078 commit 5d46c65
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def source_file_for_dependency_entry(caller, dep_entry)

p = Pathname.new caller
parent_path = p.parent
parent_path.join(dep_entry).to_s
parent_path.join(dep_entry + '.js').to_s
end

# return a Hash of dependency info, whose keys are jquery-ui
Expand All @@ -35,16 +35,22 @@ def map_dependencies

matchdata = file.match(/define\(.*\[[\S\s]+\]\, factory \);/m)

# fallback for core.js, which doesn't refer to factory
matchdata ||= file.match(/define\(.*\[[\S\s]+\](\, factory )?.*\);/m)

# skip if there's no dependencies
next if matchdata.nil?

# dirty string, with define([], factory) wrapping, comments and newlines
deps_str = matchdata[0]

# remove define([], factory) wrap
deps = deps_str.match(/\[[\s\S]*\]/)[0]

# remove lines with comments
deps = deps.gsub(/\/\/.+\s/, "")

# remove all non-path symbols, leaving only commas, dots and shashes
deps = deps.gsub(/[\r\n\t\"\[\]\s]/, "")

deps_paths = deps.split(',')
Expand All @@ -53,8 +59,6 @@ def map_dependencies
# so we remove 'jquery' from the list of dependencies for all files
deps_paths.reject! {|d| d == "jquery" }

deps_paths.map! {|d| d + '.js' }

deps_paths.map! {|d| source_file_for_dependency_entry path, d }

dependencies[basename] = deps_paths
Expand Down

0 comments on commit 5d46c65

Please sign in to comment.