Skip to content

Commit 5d46c65

Browse files
committed
add comments and do small optimization up
1 parent 45cf078 commit 5d46c65

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Rakefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def source_file_for_dependency_entry(caller, dep_entry)
2121

2222
p = Pathname.new caller
2323
parent_path = p.parent
24-
parent_path.join(dep_entry).to_s
24+
parent_path.join(dep_entry + '.js').to_s
2525
end
2626

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

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

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

41+
# skip if there's no dependencies
4042
next if matchdata.nil?
4143

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

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

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

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

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

56-
deps_paths.map! {|d| d + '.js' }
57-
5862
deps_paths.map! {|d| source_file_for_dependency_entry path, d }
5963

6064
dependencies[basename] = deps_paths

0 commit comments

Comments
 (0)