Last active
August 29, 2015 14:06
-
-
Save guilipan/efab43dc9b19504dcf7b to your computer and use it in GitHub Desktop.
parse seajs dependencies modules array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseDependencies(code) { | |
var REQUIRE_RE = /"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g; | |
var SLASH_RE = /\\\\/g; | |
var ret = [] | |
code.replace(SLASH_RE, "") | |
.replace(REQUIRE_RE, function(m, m1, m2) { | |
if (m2) { | |
ret.push(m2) | |
} | |
}) | |
return ret | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment