Skip to content

Commit d45cf46

Browse files
committed
improve regex and clean it up
1 parent 8cb2e6e commit d45cf46

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Rakefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,16 @@ def map_dependencies
3333
basename = File.basename path
3434
file = File.read path
3535

36-
matchdata = file.match(/define\(.*\[[\S\s]+\]\, factory \);/m)
36+
matchdata = file.match(/define\(\s*\[\s*([\"\.\/\,\w\s-\:]+)\]/m)
3737

38-
# fallback for core.js, which doesn't refer to factory
39-
matchdata ||= file.match(/define\(.*\[[\S\s]+\](\, factory )?.*\);/m)
40-
41-
# skip if there's no dependencies
4238
next if matchdata.nil?
4339

44-
# dirty string, with define([], factory) wrapping, comments and newlines
45-
deps_str = matchdata[0]
46-
47-
# remove define([], factory) wrap
48-
deps = deps_str.match(/\[[\s\S]*\]/)[0]
40+
deps = matchdata[1]
4941

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

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

5648
deps_paths = deps.split(',')

0 commit comments

Comments
 (0)