forked from Wizcorp/phonegap-facebook-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·28 lines (25 loc) · 1.06 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
def replace_in_file(filepath, regexp, *args, &block)
content = File.read(filepath).gsub(regexp, *args, &block)
File.open(filepath, 'wb') { |file| file.write(content) }
end
file = File.expand_path(ARGV[0])
platform = ( File.extension(file) == ".plist" ? "ios" : "android" )
if (platform == "ios")
replace_in_file(file, /\s*<key>com.phonegap.facebook.Connect<\/key>\n/mi) do |match|
""
end
replace_in_file(file, /\s*<string>FacebookConnectPlugin<\/string>\n/mi) do |match|
""
end
replace_in_file(file, /<key>Plugins<\/key>\n\s*<dict>/mi) do |match|
"<key>Plugins</key>\n\t<dict>\n\t\t<key>com.phonegap.facebook.Connect</key>\n\t\t<string>FacebookConnectPlugin</string>"
end
elsif (platform == "android")
replace_in_file(file, /<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" \/>\n/mi) do |match|
""
end
replace_in_file(file, /\s*<\/plugins>/mi) do |match|
"\t<plugin name=\"com.phonegap.facebook.Connect\" value=\"com.phonegap.facebook.ConnectPlugin\" />\n</plugins>"
end
end