Created
August 17, 2020 02:15
-
-
Save hmdne/6e8b70683b60fcc71d5a3ae3e4679a95 to your computer and use it in GitHub Desktop.
Move all stubs from an opal file to a runtime call.
This file contains hidden or 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
| require 'set' | |
| f = File.read(ARGV[0]) | |
| stubs = Set.new | |
| f = f.gsub /^ Opal\.add_stubs\(\[(.*?)\]\)/ do | |
| stubs += $1.gsub("'", '').split(', ') | |
| "" | |
| end | |
| stubs = stubs.map{|i|"'#{i}'"}.join(",") | |
| f = f.gsub %r<// Instantiate the main object>, | |
| "Opal.add_stubs([#{stubs}]);" | |
| print f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment